Merge "Add support for writeBlocking"
diff --git a/Android.bp b/Android.bp
index 05ca928..927e227 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,5 +1,6 @@
 hidl_package_root {
     name: "android.hardware",
+    use_current: true,
 }
 
 cc_defaults {
@@ -13,7 +14,10 @@
 // VTS tests must link to HAL definition libraries statically.
 cc_defaults {
     name: "VtsHalTargetTestDefaults",
-    defaults: ["hidl_defaults"],
+    defaults: [
+        "vts_target_tests_defaults",
+        "hidl_defaults",
+    ],
 
     // Lists all dependencies that can *not* be expected on the device.
     static_libs: [
diff --git a/atrace/1.0/vts/functional/Android.bp b/atrace/1.0/vts/functional/Android.bp
index 6b50fb5..d3f4276 100644
--- a/atrace/1.0/vts/functional/Android.bp
+++ b/atrace/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalAtraceV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.atrace@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/audio/4.0/config/audio_policy_configuration.xsd b/audio/4.0/config/audio_policy_configuration.xsd
index ee17fc9..58bab22 100644
--- a/audio/4.0/config/audio_policy_configuration.xsd
+++ b/audio/4.0/config/audio_policy_configuration.xsd
@@ -280,6 +280,19 @@
             <xs:enumeration value="AUDIO_DEVICE_IN_STUB"/>
         </xs:restriction>
     </xs:simpleType>
+    <xs:simpleType name="vendorExtension">
+        <!-- Vendor extension names must be prefixed by "VX_" to distinguish them from AOSP values.
+             Vendor are encouraged to namespace their module names to avoid conflicts.
+             Example for an hypothetical Google virtual reality device:
+                <devicePort tagName="VR" type="VX_GOOGLE_VR" role="sink">
+        -->
+        <xs:restriction base="xs:string">
+            <xs:pattern value="VX_[_a-zA-Z0-9]+"/>
+        </xs:restriction>
+    </xs:simpleType>
+    <xs:simpleType name="extendableAudioDevice">
+        <xs:union memberTypes="audioDevice vendorExtension"/>
+    </xs:simpleType>
     <!-- Enum values of audio_format_t in audio.h
          TODO: generate from hidl to avoid manual sync. -->
     <xs:simpleType name="audioFormat">
@@ -346,6 +359,9 @@
             <xs:enumeration value="AUDIO_FORMAT_LDAC"/>
         </xs:restriction>
     </xs:simpleType>
+    <xs:simpleType name="extendableAudioFormat">
+        <xs:union memberTypes="audioFormat vendorExtension"/>
+    </xs:simpleType>
     <!-- Enum values of audio::common::4_0::AudioUsage
          TODO: generate from HIDL to avoid manual sync. -->
     <xs:simpleType name="audioUsage">
@@ -388,7 +404,7 @@
     </xs:simpleType>
     <xs:complexType name="profile">
         <xs:attribute name="name" type="xs:token" use="optional"/>
-        <xs:attribute name="format" type="audioFormat" use="optional"/>
+        <xs:attribute name="format" type="extendableAudioFormat" use="optional"/>
         <xs:attribute name="samplingRates" type="samplingRates" use="optional"/>
         <xs:attribute name="channelMasks" type="channelMask" use="optional"/>
     </xs:complexType>
@@ -425,7 +441,7 @@
                         <xs:element name="gains" type="gains" minOccurs="0"/>
                     </xs:sequence>
                     <xs:attribute name="tagName" type="xs:token" use="required"/>
-                    <xs:attribute name="type" type="audioDevice" use="required"/>
+                    <xs:attribute name="type" type="extendableAudioDevice" use="required"/>
                     <xs:attribute name="role" type="role" use="required"/>
                     <xs:attribute name="address" type="xs:string" use="optional" default=""/>
                     <!-- Note that XSD 1.0 can not check that a type only has one default. -->
diff --git a/audio/5.0/Android.bp b/audio/5.0/Android.bp
new file mode 100644
index 0000000..27c1ef5
--- /dev/null
+++ b/audio/5.0/Android.bp
@@ -0,0 +1,48 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.audio@5.0",
+    root: "android.hardware",
+    vndk: {
+        enabled: true,
+    },
+    srcs: [
+        "types.hal",
+        "IDevice.hal",
+        "IDevicesFactory.hal",
+        "IPrimaryDevice.hal",
+        "IStream.hal",
+        "IStreamIn.hal",
+        "IStreamOut.hal",
+        "IStreamOutCallback.hal",
+    ],
+    interfaces: [
+        "android.hardware.audio.common@5.0",
+        "android.hardware.audio.effect@5.0",
+        "android.hidl.base@1.0",
+    ],
+    types: [
+        "AudioDrain",
+        "AudioFrequencyResponsePoint",
+        "AudioMicrophoneChannelMapping",
+        "AudioMicrophoneCoordinate",
+        "AudioMicrophoneDirectionality",
+        "AudioMicrophoneLocation",
+        "DeviceAddress",
+        "MessageQueueFlagBits",
+        "MicrophoneInfo",
+        "MmapBufferFlag",
+        "MmapBufferInfo",
+        "MmapPosition",
+        "ParameterValue",
+        "PlaybackTrackMetadata",
+        "RecordTrackMetadata",
+        "Result",
+        "SinkMetadata",
+        "SourceMetadata",
+        "TimeSpec",
+    ],
+    gen_java: false,
+    gen_java_constants: true,
+}
+
diff --git a/audio/5.0/IDevice.hal b/audio/5.0/IDevice.hal
new file mode 100644
index 0000000..afb4fad
--- /dev/null
+++ b/audio/5.0/IDevice.hal
@@ -0,0 +1,282 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio@5.0;
+
+import android.hardware.audio.common@5.0;
+import IStreamIn;
+import IStreamOut;
+
+interface IDevice {
+    /**
+     * Returns whether the audio hardware interface has been initialized.
+     *
+     * @return retval OK on success, NOT_INITIALIZED on failure.
+     */
+    initCheck() generates (Result retval);
+
+    /**
+     * Sets the audio volume for all audio activities other than voice call. If
+     * NOT_SUPPORTED is returned, the software mixer will emulate this
+     * capability.
+     *
+     * @param volume 1.0f means unity, 0.0f is zero.
+     * @return retval operation completion status.
+     */
+    setMasterVolume(float volume) generates (Result retval);
+
+    /**
+     * Get the current master volume value for the HAL, if the HAL supports
+     * master volume control. For example, AudioFlinger will query this value
+     * from the primary audio HAL when the service starts and use the value for
+     * setting the initial master volume across all HALs. HALs which do not
+     * support this method must return NOT_SUPPORTED in 'retval'.
+     *
+     * @return retval operation completion status.
+     * @return volume 1.0f means unity, 0.0f is zero.
+     */
+    getMasterVolume() generates (Result retval, float volume);
+
+    /**
+     * Sets microphone muting state.
+     *
+     * @param mute whether microphone is muted.
+     * @return retval operation completion status.
+     */
+    setMicMute(bool mute) generates (Result retval);
+
+    /**
+     * Gets whether microphone is muted.
+     *
+     * @return retval operation completion status.
+     * @return mute whether microphone is muted.
+     */
+    getMicMute() generates (Result retval, bool mute);
+
+    /**
+     * Set the audio mute status for all audio activities. If the return value
+     * is NOT_SUPPORTED, the software mixer will emulate this capability.
+     *
+     * @param mute whether audio is muted.
+     * @return retval operation completion status.
+     */
+    setMasterMute(bool mute) generates (Result retval);
+
+    /**
+     * Get the current master mute status for the HAL, if the HAL supports
+     * master mute control. AudioFlinger will query this value from the primary
+     * audio HAL when the service starts and use the value for setting the
+     * initial master mute across all HALs. HAL must indicate that the feature
+     * is not supported by returning NOT_SUPPORTED status.
+     *
+     * @return retval operation completion status.
+     * @return mute whether audio is muted.
+     */
+    getMasterMute() generates (Result retval, bool mute);
+
+    /**
+     * Returns audio input buffer size according to parameters passed or
+     * INVALID_ARGUMENTS if one of the parameters is not supported.
+     *
+     * @param config audio configuration.
+     * @return retval operation completion status.
+     * @return bufferSize input buffer size in bytes.
+     */
+    getInputBufferSize(AudioConfig config)
+            generates (Result retval, uint64_t bufferSize);
+
+    /**
+     * This method creates and opens the audio hardware output stream.
+     * If the stream can not be opened with the proposed audio config,
+     * HAL must provide suggested values for the audio config.
+     *
+     * @param ioHandle handle assigned by AudioFlinger.
+     * @param device device type and (if needed) address.
+     * @param config stream configuration.
+     * @param flags additional flags.
+     * @param sourceMetadata Description of the audio that will be played.
+                             May be used by implementations to configure hardware effects.
+     * @return retval operation completion status.
+     * @return outStream created output stream.
+     * @return suggestedConfig in case of invalid parameters, suggested config.
+     */
+    openOutputStream(
+            AudioIoHandle ioHandle,
+            DeviceAddress device,
+            AudioConfig config,
+            bitfield<AudioOutputFlag> flags,
+            SourceMetadata sourceMetadata) generates (
+                    Result retval,
+                    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.
+     *
+     * @param ioHandle handle assigned by AudioFlinger.
+     * @param device device type and (if needed) address.
+     * @param config stream configuration.
+     * @param flags additional flags.
+     * @param sinkMetadata Description of the audio that is suggested by the client.
+     *                     May be used by implementations to configure hardware effects.
+     * @return retval operation completion status.
+     * @return inStream in case of success, created input stream.
+     * @return suggestedConfig in case of invalid parameters, suggested config.
+     */
+    openInputStream(
+            AudioIoHandle ioHandle,
+            DeviceAddress device,
+            AudioConfig config,
+            bitfield<AudioInputFlag> flags,
+            SinkMetadata sinkMetadata) generates (
+                    Result retval,
+                    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.
+     *
+     * @param sources patch sources.
+     * @param sinks patch sinks.
+     * @return retval operation completion status.
+     * @return patch created patch handle.
+     */
+    createAudioPatch(vec<AudioPortConfig> sources, vec<AudioPortConfig> sinks)
+            generates (Result retval, AudioPatchHandle patch);
+
+    /**
+     * Release an audio patch.
+     *
+     * @param patch patch handle.
+     * @return retval operation completion status.
+     */
+    releaseAudioPatch(AudioPatchHandle patch) generates (Result retval);
+
+    /**
+     * Returns the list of supported attributes for a given audio port.
+     *
+     * As input, 'port' contains the information (type, role, address etc...)
+     * needed by the HAL to identify the port.
+     *
+     * As output, 'resultPort' contains possible attributes (sampling rates,
+     * formats, channel masks, gain controllers...) for this port.
+     *
+     * @param port port identifier.
+     * @return retval operation completion status.
+     * @return resultPort port descriptor with all parameters filled up.
+     */
+    getAudioPort(AudioPort port)
+            generates (Result retval, AudioPort resultPort);
+
+    /**
+     * Set audio port configuration.
+     *
+     * @param config audio port configuration.
+     * @return retval operation completion status.
+     */
+    setAudioPortConfig(AudioPortConfig config) generates (Result retval);
+
+    /**
+     * Gets the HW synchronization source of the device. Calling this method is
+     * equivalent to getting AUDIO_PARAMETER_HW_AV_SYNC on the legacy HAL.
+     * Optional method
+     *
+     * @return retval operation completion status: OK or NOT_SUPPORTED.
+     * @return hwAvSync HW synchronization source
+     */
+    getHwAvSync() generates (Result retval, AudioHwSync hwAvSync);
+
+    /**
+     * Sets whether the screen is on. Calling this method is equivalent to
+     * setting AUDIO_PARAMETER_KEY_SCREEN_STATE on the legacy HAL.
+     * Optional method
+     *
+     * @param turnedOn whether the screen is turned on.
+     * @return retval operation completion status.
+     */
+    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.
+     *
+     * Multiple parameters can be retrieved at the same time.
+     * The implementation should return as many requested parameters
+     * as possible, even if one or more is not supported
+     *
+     * @param context provides more information about the request
+     * @param keys keys of the requested parameters
+     * @return retval operation completion status.
+     *         OK must be returned if keys is empty.
+     *         NOT_SUPPORTED must be returned if at least one key is unknown.
+     * @return parameters parameter key value pairs.
+     *         Must contain the value of all requested keys if retval == OK
+     */
+    getParameters(vec<ParameterValue> context, 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.
+     *
+     * Multiple parameters can be set at the same time though this is
+     * discouraged as it make failure analysis harder.
+     *
+     * If possible, a failed setParameters should not impact the platform state.
+     *
+     * @param context provides more information about the request
+     * @param parameters parameter key value pairs.
+     * @return retval operation completion status.
+     *         All parameters must be successfully set for OK to be returned
+     */
+    setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
+            generates (Result retval);
+
+    /**
+     * Returns an array with available microphones in device.
+     *
+     * @return retval INVALID_STATE if the call is not successful,
+     *                OK otherwise.
+     *
+     * @return microphones array with microphones info
+     */
+    getMicrophones()
+         generates(Result retval, vec<MicrophoneInfo> microphones);
+
+    /**
+     * Notifies the device module about the connection state of an input/output
+     * device attached to it. Calling this method is equivalent to setting
+     * AUDIO_PARAMETER_DEVICE_[DIS]CONNECT on the legacy HAL.
+     *
+     * @param address audio device specification.
+     * @param connected whether the device is connected.
+     * @return retval operation completion status.
+     */
+    setConnectedState(DeviceAddress address, bool connected)
+            generates (Result retval);
+};
diff --git a/audio/5.0/IDevicesFactory.hal b/audio/5.0/IDevicesFactory.hal
new file mode 100644
index 0000000..92060e7
--- /dev/null
+++ b/audio/5.0/IDevicesFactory.hal
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio@5.0;
+
+import android.hardware.audio.common@5.0;
+import IDevice;
+import IPrimaryDevice;
+
+/** This factory allows a HAL implementation to be split in multiple independent
+ *  devices (called module in the pre-treble API).
+ *  Note that this division is arbitrary and implementation are free
+ *  to only have a Primary.
+ *  The framework will query the devices according to audio_policy_configuration.xml
+ *
+ *  Each device name is arbitrary, provided by the vendor's audio_policy_configuration.xml
+ *  and only used to identify a device in this factory.
+ *  The framework must not interpret the name, treating it as a vendor opaque data
+ *  with the following exception:
+ *  - the "r_submix" device that must be present to support policyMixes (Eg: Android projected).
+ *    Note that this Device is included by default in a build derived from AOSP.
+ *
+ *  Note that on AOSP Oreo (including MR1) the "a2dp" module is not using this API
+ *  but is loaded directly from the system partition using the legacy API
+ *  due to limitations with the Bluetooth framework.
+ */
+interface IDevicesFactory {
+
+    /**
+     * Opens an audio device. To close the device, it is necessary to release
+     * references to the returned device object.
+     *
+     * @param device device name.
+     * @return retval operation completion status. Returns INVALID_ARGUMENTS
+     *         if there is no corresponding hardware module found,
+     *         NOT_INITIALIZED if an error occured while opening the hardware
+     *         module.
+     * @return result the interface for the created device.
+     */
+    openDevice(string device) generates (Result retval, IDevice result);
+
+    /**
+     * Opens the Primary audio device that must be present.
+     * This function is not optional and must return successfully the primary device.
+     *
+     * This device must have the name "primary".
+     *
+     * The telephony stack uses this device to control the audio during a voice call.
+     *
+     * @return retval operation completion status. Must be SUCCESS.
+     *         For debuging, return INVALID_ARGUMENTS if there is no corresponding
+     *         hardware module found, NOT_INITIALIZED if an error occurred
+     *         while opening the hardware module.
+     * @return result the interface for the created device.
+     */
+    openPrimaryDevice() generates (Result retval, IPrimaryDevice result);
+};
diff --git a/audio/5.0/IPrimaryDevice.hal b/audio/5.0/IPrimaryDevice.hal
new file mode 100644
index 0000000..60add5a
--- /dev/null
+++ b/audio/5.0/IPrimaryDevice.hal
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio@5.0;
+
+import android.hardware.audio.common@5.0;
+import IDevice;
+
+interface IPrimaryDevice extends IDevice {
+    /**
+     * Sets the audio volume of a voice call.
+     *
+     * @param volume 1.0f means unity, 0.0f is zero.
+     * @return retval operation completion status.
+     */
+    setVoiceVolume(float volume) generates (Result retval);
+
+    /**
+     * This method is used to notify the HAL about audio mode changes.
+     *
+     * @param mode new mode.
+     * @return retval operation completion status.
+     */
+    setMode(AudioMode mode) generates (Result retval);
+
+    /**
+     * Sets the name of the current BT SCO headset. Calling this method
+     * is equivalent to setting legacy "bt_headset_name" parameter.
+     * The BT SCO headset name must only be used for debugging purposes.
+     * Optional method
+     *
+     * @param name the name of the current BT SCO headset (can be empty).
+     * @return retval operation completion status.
+     */
+    setBtScoHeadsetDebugName(string name) generates (Result retval);
+
+    /**
+     * Gets whether BT SCO Noise Reduction and Echo Cancellation are enabled.
+     * Calling this method is equivalent to getting AUDIO_PARAMETER_KEY_BT_NREC
+     * on the legacy HAL.
+     *
+     * @return retval operation completion status.
+     * @return enabled whether BT SCO NR + EC are enabled.
+     */
+    getBtScoNrecEnabled() generates (Result retval, bool enabled);
+
+    /**
+     * Sets whether BT SCO Noise Reduction and Echo Cancellation are enabled.
+     * Calling this method is equivalent to setting AUDIO_PARAMETER_KEY_BT_NREC
+     * on the legacy HAL.
+     * Optional method
+     *
+     * @param enabled whether BT SCO NR + EC are enabled.
+     * @return retval operation completion status.
+     */
+    setBtScoNrecEnabled(bool enabled) generates (Result retval);
+
+    /**
+     * Gets whether BT SCO Wideband mode is enabled. Calling this method is
+     * equivalent to getting AUDIO_PARAMETER_KEY_BT_SCO_WB on the legacy HAL.
+     *
+     * @return retval operation completion status.
+     * @return enabled whether BT Wideband is enabled.
+     */
+    getBtScoWidebandEnabled() generates (Result retval, bool enabled);
+
+    /**
+     * Sets whether BT SCO Wideband mode is enabled. Calling this method is
+     * equivalent to setting AUDIO_PARAMETER_KEY_BT_SCO_WB on the legacy HAL.
+     * Optional method
+     *
+     * @param enabled whether BT Wideband is enabled.
+     * @return retval operation completion status.
+     */
+    setBtScoWidebandEnabled(bool enabled) generates (Result retval);
+
+    /**
+     * Gets whether BT HFP (Hands-Free Profile) is enabled. Calling this method
+     * is equivalent to getting "hfp_enable" parameter value on the legacy HAL.
+     *
+     * @return retval operation completion status.
+     * @return enabled whether BT HFP is enabled.
+     */
+    getBtHfpEnabled() generates (Result retval, bool enabled);
+
+    /**
+     * Sets whether BT HFP (Hands-Free Profile) is enabled. Calling this method
+     * is equivalent to setting "hfp_enable" parameter on the legacy HAL.
+     * Optional method
+     *
+     * @param enabled whether BT HFP is enabled.
+     * @return retval operation completion status.
+     */
+    setBtHfpEnabled(bool enabled) generates (Result retval);
+
+    /**
+     * Sets the sampling rate of BT HFP (Hands-Free Profile). Calling this
+     * method is equivalent to setting "hfp_set_sampling_rate" parameter
+     * on the legacy HAL.
+     * Optional method
+     *
+     * @param sampleRateHz sample rate in Hz.
+     * @return retval operation completion status.
+     */
+    setBtHfpSampleRate(uint32_t sampleRateHz) generates (Result retval);
+
+    /**
+     * Sets the current output volume Hz for BT HFP (Hands-Free Profile).
+     * Calling this method is equivalent to setting "hfp_volume" parameter value
+     * on the legacy HAL (except that legacy HAL implementations expect
+     * an integer value in the range from 0 to 15.)
+     * Optional method
+     *
+     * @param volume 1.0f means unity, 0.0f is zero.
+     * @return retval operation completion status.
+     */
+    setBtHfpVolume(float volume) generates (Result retval);
+
+    enum TtyMode : int32_t {
+        OFF,
+        VCO,
+        HCO,
+        FULL
+    };
+
+    /**
+     * Gets current TTY mode selection. Calling this method is equivalent to
+     * getting AUDIO_PARAMETER_KEY_TTY_MODE on the legacy HAL.
+     *
+     * @return retval operation completion status.
+     * @return mode TTY mode.
+     */
+    getTtyMode() generates (Result retval, TtyMode mode);
+
+    /**
+     * Sets current TTY mode. Calling this method is equivalent to setting
+     * AUDIO_PARAMETER_KEY_TTY_MODE on the legacy HAL.
+     *
+     * @param mode TTY mode.
+     * @return retval operation completion status.
+     */
+    setTtyMode(TtyMode mode) generates (Result retval);
+
+    /**
+     * Gets whether Hearing Aid Compatibility - Telecoil (HAC-T) mode is
+     * enabled. Calling this method is equivalent to getting
+     * AUDIO_PARAMETER_KEY_HAC on the legacy HAL.
+     *
+     * @return retval operation completion status.
+     * @return enabled whether HAC mode is enabled.
+     */
+    getHacEnabled() generates (Result retval, bool enabled);
+
+    /**
+     * Sets whether Hearing Aid Compatibility - Telecoil (HAC-T) mode is
+     * enabled. Calling this method is equivalent to setting
+     * AUDIO_PARAMETER_KEY_HAC on the legacy HAL.
+     * Optional method
+     *
+     * @param enabled whether HAC mode is enabled.
+     * @return retval operation completion status.
+     */
+    setHacEnabled(bool enabled) generates (Result retval);
+
+    enum Rotation : int32_t {
+        DEG_0,
+        DEG_90,
+        DEG_180,
+        DEG_270
+    };
+
+    /**
+     * Updates HAL on the current rotation of the device relative to natural
+     * orientation. Calling this method is equivalent to setting legacy
+     * parameter "rotation".
+     *
+     * @param rotation rotation in degrees relative to natural device
+     *     orientation.
+     * @return retval operation completion status.
+     */
+    updateRotation(Rotation rotation) generates (Result retval);
+};
diff --git a/audio/5.0/IStream.hal b/audio/5.0/IStream.hal
new file mode 100644
index 0000000..0f975b6
--- /dev/null
+++ b/audio/5.0/IStream.hal
@@ -0,0 +1,310 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio@5.0;
+
+import android.hardware.audio.common@5.0;
+import android.hardware.audio.effect@5.0::IEffect;
+
+interface IStream {
+    /**
+     * Return the frame size (number of bytes per sample).
+     *
+     * @return frameSize frame size in bytes.
+     */
+    getFrameSize() generates (uint64_t frameSize);
+
+    /**
+     * Return the frame count of the buffer. Calling this method is equivalent
+     * to getting AUDIO_PARAMETER_STREAM_FRAME_COUNT on the legacy HAL.
+     *
+     * @return count frame count.
+     */
+    getFrameCount() generates (uint64_t count);
+
+    /**
+     * Return the size of input/output buffer in bytes for this stream.
+     * It must be a multiple of the frame size.
+     *
+     * @return buffer buffer size in bytes.
+     */
+    getBufferSize() generates (uint64_t bufferSize);
+
+    /**
+     * Return the sampling rate in Hz.
+     *
+     * @return sampleRateHz sample rate in Hz.
+     */
+    getSampleRate() generates (uint32_t sampleRateHz);
+
+    /**
+     * Return supported native sampling rates of the stream for a given format.
+     * A supported native sample rate is a sample rate that can be efficiently
+     * played by the hardware (typically without sample-rate conversions).
+     *
+     * This function is only called for dynamic profile. If called for
+     * non-dynamic profile is should return NOT_SUPPORTED or the same list
+     * as in audio_policy_configuration.xml.
+     *
+     * Calling this method is equivalent to getting
+     * AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES on the legacy HAL.
+     *
+     *
+     * @param format audio format for which the sample rates are supported.
+     * @return retval operation completion status.
+     *                Must be OK if the format is supported.
+     * @return sampleRateHz supported sample rates.
+     */
+    getSupportedSampleRates(AudioFormat format)
+            generates (Result retval, 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.
+     * Optional method. If implemented, only called on a stopped stream.
+     *
+     * @param sampleRateHz sample rate in Hz.
+     * @return retval operation completion status.
+     */
+    setSampleRate(uint32_t sampleRateHz) generates (Result retval);
+
+    /**
+     * Return the channel mask of the stream.
+     *
+     * @return mask channel mask.
+     */
+    getChannelMask() generates (bitfield<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.
+     *
+     * @param format audio format for which the channel masks are supported.
+     * @return retval operation completion status.
+     *                Must be OK if the format is supported.
+     * @return masks supported audio masks.
+     */
+    getSupportedChannelMasks(AudioFormat format)
+            generates (Result retval, vec<bitfield<AudioChannelMask>> masks);
+
+    /**
+     * Sets the channel mask of the stream. Calling this method is equivalent to
+     * setting AUDIO_PARAMETER_STREAM_CHANNELS on the legacy HAL.
+     * Optional method
+     *
+     * @param format audio format.
+     * @return retval operation completion status.
+     */
+    setChannelMask(bitfield<AudioChannelMask> mask) generates (Result retval);
+
+    /**
+     * Return the audio format of the stream.
+     *
+     * @return format audio format.
+     */
+    getFormat() generates (AudioFormat format);
+
+    /**
+     * Return supported audio formats of the stream. Calling this method is
+     * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_FORMATS on the legacy
+     * HAL.
+     *
+     * @return formats supported audio formats.
+     */
+    getSupportedFormats() generates (vec<AudioFormat> formats);
+
+    /**
+     * Sets the audio format of the stream. Calling this method is equivalent to
+     * setting AUDIO_PARAMETER_STREAM_FORMAT on the legacy HAL.
+     * Optional method
+     *
+     * @param format audio format.
+     * @return retval operation completion status.
+     */
+    setFormat(AudioFormat format) generates (Result retval);
+
+    /**
+     * Convenience method for retrieving several stream parameters in
+     * one transaction.
+     *
+     * @return sampleRateHz sample rate in Hz.
+     * @return mask channel mask.
+     * @return format audio format.
+     */
+    getAudioProperties() generates (
+            uint32_t sampleRateHz, bitfield<AudioChannelMask> mask, AudioFormat format);
+
+    /**
+     * Applies audio effect to the stream.
+     *
+     * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
+     *                 the effect to apply.
+     * @return retval operation completion status.
+     */
+    addEffect(uint64_t effectId) generates (Result retval);
+
+    /**
+     * Stops application of the effect to the stream.
+     *
+     * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
+     *                 the effect to remove.
+     * @return retval operation completion status.
+     */
+    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.
+     *
+     * @return retval operation completion status.
+     */
+    standby() generates (Result retval);
+
+    /**
+     * Return the set of devices which this stream is connected to.
+     * Optional method
+     *
+     * @return retval operation completion status: OK or NOT_SUPPORTED.
+     * @return device set of devices which this stream is connected to.
+     */
+    getDevices() generates (Result retval, vec<DeviceAddress> devices);
+
+    /**
+     * Connects the stream to one or multiple devices.
+     *
+     * This method must only be used for HALs that do not support
+     * 'IDevice.createAudioPatch' method. Calling this method is
+     * equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING preceeded
+     * with a device address in the legacy HAL interface.
+     *
+     * @param address device to connect the stream to.
+     * @return retval operation completion status.
+     */
+    setDevices(vec<DeviceAddress> devices) 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.
+     * Optional method
+     *
+     * @param hwAvSync HW synchronization source
+     * @return retval operation completion status.
+     */
+    setHwAvSync(AudioHwSync hwAvSync) generates (Result retval);
+
+    /**
+     * Generic method for retrieving vendor-specific parameter values.
+     * The framework does not interpret the parameters, they are passed
+     * in an opaque manner between a vendor application and HAL.
+     *
+     * Multiple parameters can be retrieved at the same time.
+     * The implementation should return as many requested parameters
+     * as possible, even if one or more is not supported
+     *
+     * @param context provides more information about the request
+     * @param keys keys of the requested parameters
+     * @return retval operation completion status.
+     *         OK must be returned if keys is empty.
+     *         NOT_SUPPORTED must be returned if at least one key is unknown.
+     * @return parameters parameter key value pairs.
+     *         Must contain the value of all requested keys if retval == OK
+     */
+    getParameters(vec<ParameterValue> context, 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.
+     *
+     * Multiple parameters can be set at the same time though this is
+     * discouraged as it make failure analysis harder.
+     *
+     * If possible, a failed setParameters should not impact the platform state.
+     *
+     * @param context provides more information about the request
+     * @param parameters parameter key value pairs.
+     * @return retval operation completion status.
+     *         All parameters must be successfully set for OK to be returned
+     */
+    setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
+            generates (Result retval);
+
+    /**
+     * 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.
+     *
+     * @return retval OK in case the success.
+     *                NOT_SUPPORTED on non mmap mode streams
+     *                INVALID_STATE if called out of sequence
+     */
+    start() generates (Result retval);
+
+    /**
+     * Called by the framework to stop a stream operating in mmap mode.
+     * Function only implemented by streams operating in mmap mode.
+     *
+     * @return retval OK in case the succes.
+     *                NOT_SUPPORTED on non mmap mode streams
+     *                INVALID_STATE if called out of sequence
+     */
+    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.
+     *
+     * @param minSizeFrames minimum buffer size requested. The actual buffer
+     *                     size returned in struct MmapBufferInfo can be larger.
+     * @return retval OK in case the success.
+     *                NOT_SUPPORTED on non mmap mode streams
+     *                NOT_INITIALIZED in case of memory allocation error
+     *                INVALID_ARGUMENTS if the requested buffer size is too large
+     *                INVALID_STATE if called out of sequence
+     * @return info    a MmapBufferInfo struct containing information on the MMMAP buffer created.
+     */
+    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.
+     *
+     * @return retval OK in case the success.
+     *                NOT_SUPPORTED on non mmap mode streams
+     *                INVALID_STATE if called out of sequence
+     * @return position a MmapPosition struct containing current HW read/write position in frames
+     *                  with associated time stamp.
+     */
+    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.
+     *
+     * @return retval OK in case the success.
+     *                NOT_SUPPORTED if called on IStream instead of input or
+     *                              output stream interface.
+     *                INVALID_STATE if the stream was already closed.
+     */
+    close() generates (Result retval);
+};
diff --git a/audio/5.0/IStreamIn.hal b/audio/5.0/IStreamIn.hal
new file mode 100644
index 0000000..d33cfdc
--- /dev/null
+++ b/audio/5.0/IStreamIn.hal
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio@5.0;
+
+import android.hardware.audio.common@5.0;
+import IStream;
+
+interface IStreamIn extends IStream {
+    /**
+     * Returns the source descriptor of the input stream. Calling this method is
+     * equivalent to getting AUDIO_PARAMETER_STREAM_INPUT_SOURCE on the legacy
+     * HAL.
+     * Optional method
+     *
+     * @return retval operation completion status.
+     * @return source audio source.
+     */
+    getAudioSource() generates (Result retval, AudioSource source);
+
+    /**
+     * Set the input gain for the audio driver.
+     * Optional method
+     *
+     * @param gain 1.0f is unity, 0.0f is zero.
+     * @result retval operation completion status.
+     */
+    setGain(float gain) generates (Result retval);
+
+    /**
+     * Commands that can be executed on the driver reader thread.
+     */
+    enum ReadCommand : int32_t {
+        READ,
+        GET_CAPTURE_POSITION
+    };
+
+    /**
+     * Data structure passed to the driver for executing commands
+     * on the driver reader thread.
+     */
+    struct ReadParameters {
+        ReadCommand command;  // discriminator
+        union Params {
+            uint64_t read;    // READ command, amount of bytes to read, >= 0.
+            // No parameters for GET_CAPTURE_POSITION.
+        } params;
+    };
+
+    /**
+     * Data structure passed back to the client via status message queue
+     * of 'read' operation.
+     *
+     * Possible values of 'retval' field:
+     *  - OK, read operation was successful;
+     *  - INVALID_ARGUMENTS, stream was not configured properly;
+     *  - INVALID_STATE, stream is in a state that doesn't allow reads.
+     */
+    struct ReadStatus {
+        Result retval;
+        ReadCommand replyTo;  // discriminator
+        union Reply {
+            uint64_t read;    // READ command, amount of bytes read, >= 0.
+            struct CapturePosition { // same as generated by getCapturePosition.
+                uint64_t frames;
+                uint64_t time;
+            } capturePosition;
+        } reply;
+    };
+
+    /**
+     * Called when the metadata of the stream's sink has been changed.
+     * @param sinkMetadata Description of the audio that is suggested by the clients.
+     */
+    updateSinkMetadata(SinkMetadata sinkMetadata);
+
+    /**
+     * Set up required transports for receiving audio buffers from the driver.
+     *
+     * The transport consists of three message queues:
+     *  -- command queue is used to instruct the reader thread what operation
+     *     to perform;
+     *  -- data queue is used for passing audio data from the driver
+     *     to the client;
+     *  -- status queue is used for reporting operation status
+     *     (e.g. amount of bytes actually read or error code).
+     *
+     * The driver operates on a dedicated thread. The client must ensure that
+     * the thread is given an appropriate priority and assigned to correct
+     * scheduler and cgroup. For this purpose, the method returns identifiers
+     * of the driver thread.
+     *
+     * @param frameSize the size of a single frame, in bytes.
+     * @param framesCount the number of frames in a buffer.
+     * @param threadPriority priority of the driver thread.
+     * @return retval OK if both message queues were created successfully.
+     *                INVALID_STATE if the method was already called.
+     *                INVALID_ARGUMENTS if there was a problem setting up
+     *                                  the queues.
+     * @return commandMQ a message queue used for passing commands.
+     * @return dataMQ a message queue used for passing audio data in the format
+     *                specified at the stream opening.
+     * @return statusMQ a message queue used for passing status from the driver
+     *                  using ReadStatus structures.
+     * @return threadInfo identifiers of the driver's dedicated thread.
+     */
+    prepareForReading(uint32_t frameSize, uint32_t framesCount)
+    generates (
+            Result retval,
+            fmq_sync<ReadParameters> commandMQ,
+            fmq_sync<uint8_t> dataMQ,
+            fmq_sync<ReadStatus> statusMQ,
+            ThreadInfo threadInfo);
+
+    /**
+     * Return the amount of input frames lost in the audio driver since the last
+     * call of this function.
+     *
+     * Audio driver is expected to reset the value to 0 and restart counting
+     * upon returning the current value by this function call. Such loss
+     * typically occurs when the user space process is blocked longer than the
+     * capacity of audio driver buffers.
+     *
+     * @return framesLost the number of input audio frames lost.
+     */
+    getInputFramesLost() generates (uint32_t framesLost);
+
+    /**
+     * Return a recent count of the number of audio frames received and the
+     * clock time associated with that frame count.
+     *
+     * @return retval INVALID_STATE if the device is not ready/available,
+     *                NOT_SUPPORTED if the command is not supported,
+     *                OK otherwise.
+     * @return frames the total frame count received. This must be as early in
+     *                the capture pipeline as possible. In general, frames
+     *                must be non-negative and must not go "backwards".
+     * @return time is the clock monotonic time when frames was measured. In
+     *              general, time must be a positive quantity and must not
+     *              go "backwards".
+     */
+    getCapturePosition()
+            generates (Result retval, uint64_t frames, uint64_t time);
+
+    /**
+     * Returns an array with active microphones in the stream.
+     *
+     * @return retval INVALID_STATE if the call is not successful,
+     *                OK otherwise.
+     *
+     * @return microphones array with microphones info
+     */
+    getActiveMicrophones()
+               generates(Result retval, vec<MicrophoneInfo> microphones);
+};
diff --git a/audio/5.0/IStreamOut.hal b/audio/5.0/IStreamOut.hal
new file mode 100644
index 0000000..119a642
--- /dev/null
+++ b/audio/5.0/IStreamOut.hal
@@ -0,0 +1,279 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio@5.0;
+
+import android.hardware.audio.common@5.0;
+import IStream;
+import IStreamOutCallback;
+
+interface IStreamOut extends IStream {
+    /**
+     * Return the audio hardware driver estimated latency in milliseconds.
+     *
+     * @return latencyMs latency in milliseconds.
+     */
+    getLatency() generates (uint32_t latencyMs);
+
+    /**
+     * This method is used in situations where audio mixing is done in the
+     * hardware. This method serves as a direct interface with hardware,
+     * allowing to directly set the volume as apposed to via the framework.
+     * This method might produce multiple PCM outputs or hardware accelerated
+     * codecs, such as MP3 or AAC.
+     * Optional method
+     *
+     * @param left left channel attenuation, 1.0f is unity, 0.0f is zero.
+     * @param right right channel attenuation, 1.0f is unity, 0.0f is zero.
+     * @return retval operation completion status.
+     *        If a volume is outside [0,1], return INVALID_ARGUMENTS
+     */
+    setVolume(float left, float right) generates (Result retval);
+
+    /**
+     * Commands that can be executed on the driver writer thread.
+     */
+    enum WriteCommand : int32_t {
+        WRITE,
+        GET_PRESENTATION_POSITION,
+        GET_LATENCY
+    };
+
+    /**
+     * Data structure passed back to the client via status message queue
+     * of 'write' operation.
+     *
+     * Possible values of 'retval' field:
+     *  - OK, write operation was successful;
+     *  - INVALID_ARGUMENTS, stream was not configured properly;
+     *  - INVALID_STATE, stream is in a state that doesn't allow writes;
+     *  - INVALID_OPERATION, retrieving presentation position isn't supported.
+     */
+    struct WriteStatus {
+        Result retval;
+        WriteCommand replyTo;  // discriminator
+        union Reply {
+            uint64_t written;  // WRITE command, amount of bytes written, >= 0.
+            struct PresentationPosition {  // same as generated by
+                uint64_t frames;           // getPresentationPosition.
+                TimeSpec timeStamp;
+            } presentationPosition;
+            uint32_t latencyMs; // Same as generated by getLatency.
+        } reply;
+    };
+
+    /**
+     * Called when the metadata of the stream's source has been changed.
+     * @param sourceMetadata Description of the audio that is played by the clients.
+     */
+    updateSourceMetadata(SourceMetadata sourceMetadata);
+
+    /**
+     * Set up required transports for passing audio buffers to the driver.
+     *
+     * The transport consists of three message queues:
+     *  -- command queue is used to instruct the writer thread what operation
+     *     to perform;
+     *  -- data queue is used for passing audio data from the client
+     *     to the driver;
+     *  -- status queue is used for reporting operation status
+     *     (e.g. amount of bytes actually written or error code).
+     *
+     * The driver operates on a dedicated thread. The client must ensure that
+     * the thread is given an appropriate priority and assigned to correct
+     * scheduler and cgroup. For this purpose, the method returns identifiers
+     * of the driver thread.
+     *
+     * @param frameSize the size of a single frame, in bytes.
+     * @param framesCount the number of frames in a buffer.
+     * @return retval OK if both message queues were created successfully.
+     *                INVALID_STATE if the method was already called.
+     *                INVALID_ARGUMENTS if there was a problem setting up
+     *                                  the queues.
+     * @return commandMQ a message queue used for passing commands.
+     * @return dataMQ a message queue used for passing audio data in the format
+     *                specified at the stream opening.
+     * @return statusMQ a message queue used for passing status from the driver
+     *                  using WriteStatus structures.
+     * @return threadInfo identifiers of the driver's dedicated thread.
+     */
+    prepareForWriting(uint32_t frameSize, uint32_t framesCount)
+    generates (
+            Result retval,
+            fmq_sync<WriteCommand> commandMQ,
+            fmq_sync<uint8_t> dataMQ,
+            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.
+     * Optional method
+     *
+     * @return retval operation completion status.
+     * @return dspFrames number of audio frames written.
+     */
+    getRenderPosition() generates (Result retval, uint32_t dspFrames);
+
+    /**
+     * Get the local time at which the next write to the audio driver will be
+     * presented. The units are microseconds, where the epoch is decided by the
+     * local audio HAL.
+     * Optional method
+     *
+     * @return retval operation completion status.
+     * @return timestampUs time of the next write.
+     */
+    getNextWriteTimestamp() generates (Result retval, int64_t timestampUs);
+
+    /**
+     * Set the callback interface for notifying completion of non-blocking
+     * write and drain.
+     *
+     * Calling this function implies that all future 'write' and 'drain'
+     * must be non-blocking and use the callback to signal completion.
+     *
+     * 'clearCallback' method needs to be called in order to release the local
+     * callback proxy on the server side and thus dereference the callback
+     * implementation on the client side.
+     *
+     * @return retval operation completion status.
+     */
+    setCallback(IStreamOutCallback callback) generates (Result retval);
+
+    /**
+     * Clears the callback previously set via 'setCallback' method.
+     *
+     * Warning: failure to call this method results in callback implementation
+     * on the client side being held until the HAL server termination.
+     *
+     * If no callback was previously set, the method should be a no-op
+     * and return OK.
+     *
+     * @return retval operation completion status: OK or NOT_SUPPORTED.
+     */
+    clearCallback() generates (Result retval);
+
+    /**
+     * Returns whether HAL supports pausing and resuming of streams.
+     *
+     * @return supportsPause true if pausing is supported.
+     * @return supportsResume true if resume is supported.
+     */
+    supportsPauseAndResume()
+            generates (bool supportsPause, bool supportsResume);
+
+    /**
+     * Notifies to the audio driver to stop playback however the queued buffers
+     * are retained by the hardware. Useful for implementing pause/resume. Empty
+     * implementation if not supported however must be implemented for hardware
+     * with non-trivial latency. In the pause state, some audio hardware may
+     * still be using power. Client code may consider calling 'suspend' after a
+     * timeout to prevent that excess power usage.
+     *
+     * Implementation of this function is mandatory for offloaded playback.
+     *
+     * @return retval operation completion status.
+     */
+    pause() generates (Result retval);
+
+    /**
+     * Notifies to the audio driver to resume playback following a pause.
+     * Returns error INVALID_STATE if called without matching pause.
+     *
+     * Implementation of this function is mandatory for offloaded playback.
+     *
+     * @return retval operation completion status.
+     */
+    resume() generates (Result retval);
+
+    /**
+     * Returns whether HAL supports draining of streams.
+     *
+     * @return supports true if draining is supported.
+     */
+    supportsDrain() generates (bool supports);
+
+    /**
+     * Requests notification when data buffered by the driver/hardware has been
+     * played. If 'setCallback' has previously been called to enable
+     * non-blocking mode, then 'drain' must not block, instead it must return
+     * quickly and completion of the drain is notified through the callback. If
+     * 'setCallback' has not been called, then 'drain' must block until
+     * completion.
+     *
+     * If 'type' is 'ALL', the drain completes when all previously written data
+     * has been played.
+     *
+     * If 'type' is 'EARLY_NOTIFY', the drain completes shortly before all data
+     * for the current track has played to allow time for the framework to
+     * perform a gapless track switch.
+     *
+     * Drain must return immediately on 'stop' and 'flush' calls.
+     *
+     * Implementation of this function is mandatory for offloaded playback.
+     *
+     * @param type type of drain.
+     * @return retval operation completion status.
+     */
+    drain(AudioDrain type) generates (Result retval);
+
+    /**
+     * Notifies to the audio driver to flush the queued data. Stream must
+     * already be paused before calling 'flush'.
+     * Optional method
+     *
+     * Implementation of this function is mandatory for offloaded playback.
+     *
+     * @return retval operation completion status.
+     */
+    flush() generates (Result retval);
+
+    /**
+     * Return a recent count of the number of audio frames presented to an
+     * external observer. This excludes frames which have been written but are
+     * still in the pipeline. The count is not reset to zero when output enters
+     * standby. Also returns the value of CLOCK_MONOTONIC as of this
+     * presentation count. The returned count is expected to be 'recent', but
+     * does not need to be the most recent possible value. However, the
+     * associated time must correspond to whatever count is returned.
+     *
+     * Example: assume that N+M frames have been presented, where M is a 'small'
+     * number. Then it is permissible to return N instead of N+M, and the
+     * timestamp must correspond to N rather than N+M. The terms 'recent' and
+     * 'small' are not defined. They reflect the quality of the implementation.
+     *
+     * Optional method
+     *
+     * @return retval operation completion status.
+     * @return frames count of presented audio frames.
+     * @return timeStamp associated clock time.
+     */
+    getPresentationPosition()
+            generates (Result retval, uint64_t frames, TimeSpec timeStamp);
+
+    /**
+     * Selects a presentation for decoding from a next generation media stream
+     * (as defined per ETSI TS 103 190-2) and a program within the presentation.
+     * Optional method
+     *
+     * @param presentationId selected audio presentation.
+     * @param programId refinement for the presentation.
+     * @return retval operation completion status.
+     */
+    selectPresentation(int32_t presentationId, int32_t programId)
+            generates (Result retval);
+};
diff --git a/audio/common/4.0/default/HidlUtils.h b/audio/5.0/IStreamOutCallback.hal
similarity index 64%
rename from audio/common/4.0/default/HidlUtils.h
rename to audio/5.0/IStreamOutCallback.hal
index 91e6a9e..c52a040 100644
--- a/audio/common/4.0/default/HidlUtils.h
+++ b/audio/5.0/IStreamOutCallback.hal
@@ -14,13 +14,24 @@
  * limitations under the License.
  */
 
-#ifndef android_hardware_audio_V4_0_Hidl_Utils_H_
-#define android_hardware_audio_V4_0_Hidl_Utils_H_
+package android.hardware.audio@5.0;
 
-#include <android/hardware/audio/common/4.0/types.h>
+/**
+ * Asynchronous write callback interface.
+ */
+interface IStreamOutCallback {
+    /**
+     * Non blocking write completed.
+     */
+    oneway onWriteReady();
 
-#define AUDIO_HAL_VERSION V4_0
-#include <common/all-versions/default/HidlUtils.h>
-#undef AUDIO_HAL_VERSION
+    /**
+     * Drain completed.
+     */
+    oneway onDrainReady();
 
-#endif  // android_hardware_audio_V4_0_Hidl_Utils_H_
+    /**
+     * Stream hit an error.
+     */
+    oneway onError();
+};
diff --git a/audio/4.1/config/audio_policy_configuration.xsd b/audio/5.0/config/audio_policy_configuration.xsd
similarity index 100%
rename from audio/4.1/config/audio_policy_configuration.xsd
rename to audio/5.0/config/audio_policy_configuration.xsd
diff --git a/audio/5.0/types.hal b/audio/5.0/types.hal
new file mode 100644
index 0000000..988f584
--- /dev/null
+++ b/audio/5.0/types.hal
@@ -0,0 +1,246 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio@5.0;
+
+import android.hardware.audio.common@5.0;
+
+enum Result : int32_t {
+    OK,
+    NOT_INITIALIZED,
+    INVALID_ARGUMENTS,
+    INVALID_STATE,
+    /**
+     * Methods marked as "Optional method" must return this result value
+     * if the operation is not supported by HAL.
+     */
+    NOT_SUPPORTED
+};
+
+@export(name="audio_drain_type_t", value_prefix="AUDIO_DRAIN_")
+enum AudioDrain : int32_t {
+    /** drain() returns when all data has been played. */
+    ALL,
+    /**
+     * drain() returns a short time before all data from the current track has
+     * been played to give time for gapless track switch.
+     */
+    EARLY_NOTIFY
+};
+
+/**
+ * A substitute for POSIX timespec.
+ */
+struct TimeSpec {
+    uint64_t tvSec;   // seconds
+    uint64_t tvNSec;  // nanoseconds
+};
+
+/**
+ * IEEE 802 MAC address.
+ */
+typedef uint8_t[6] MacAddress;
+
+struct ParameterValue {
+    string key;
+    string value;
+};
+
+/**
+ * Specifies a device in case when several devices of the same type
+ * can be connected (e.g. BT A2DP, USB).
+ */
+struct DeviceAddress {
+    AudioDevice device;  // discriminator
+    union Address {
+        MacAddress mac;     // used for BLUETOOTH_A2DP_*
+        uint8_t[4] ipv4;    // used for IP
+        struct Alsa {
+            int32_t card;
+            int32_t device;
+        } alsa;             // used for USB_*
+    } address;
+    string busAddress;      // used for BUS
+    string rSubmixAddress;  // used for REMOTE_SUBMIX
+};
+
+enum MmapBufferFlag : uint32_t {
+    NONE    = 0x0,
+    /**
+     * If the buffer can be securely shared to untrusted applications
+     * through the AAudio exclusive mode.
+     * Only set this flag if applications are restricted from accessing the
+     * memory surrounding the audio data buffer by a kernel mechanism.
+     * See Linux kernel's dma_buf.
+     */
+    APPLICATION_SHAREABLE    = 0x1,
+};
+
+/**
+ * Mmap buffer descriptor returned by IStream.createMmapBuffer().
+ * Used by streams opened in mmap mode.
+ */
+struct MmapBufferInfo {
+    /** Mmap memory buffer */
+    memory  sharedMemory;
+    /** Total buffer size in frames */
+    uint32_t bufferSizeFrames;
+    /** Transfer size granularity in frames */
+    uint32_t burstSizeFrames;
+    /** Attributes describing the buffer. */
+    bitfield<MmapBufferFlag> flags;
+};
+
+/**
+ * Mmap buffer read/write position returned by IStream.getMmapPosition().
+ * Used by streams opened in mmap mode.
+ */
+struct MmapPosition {
+    int64_t  timeNanoseconds; // time stamp in ns, CLOCK_MONOTONIC
+    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.
+ */
+enum MessageQueueFlagBits : uint32_t {
+    NOT_EMPTY = 1 << 0,
+    NOT_FULL = 1 << 1
+};
+
+/*
+ * Microphone information
+ *
+ */
+
+/**
+ * A 3D point used to represent position or orientation of a microphone.
+ *
+ * Position: Coordinates of the microphone's capsule, in meters, from the
+ * bottom-left-back corner of the bounding box of android device in natural
+ * orientation (PORTRAIT for phones, LANDSCAPE for tablets, tvs, etc).
+ * The orientation musth match the reported by the api Display.getRotation().
+ *
+ * Orientation: Normalized vector to signal the main orientation of the
+ * microphone's capsule. Magnitude = sqrt(x^2 + y^2 + z^2) = 1
+ */
+struct AudioMicrophoneCoordinate {
+    float x;
+    float y;
+    float z;
+};
+
+/**
+ * Enum to identify the type of channel mapping for active microphones.
+ * Used channels further identify if the microphone has any significative
+ * process (e.g. High Pass Filtering, dynamic compression)
+ * Simple processing as constant gain adjustment must be DIRECT.
+ */
+enum AudioMicrophoneChannelMapping : uint32_t {
+    UNUSED      = 0, /* Channel not used */
+    DIRECT      = 1, /* Channel used and signal not processed */
+    PROCESSED   = 2, /* Channel used and signal has some process */
+};
+
+/**
+ * Enum to identify locations of microphones in regards to the body of the
+ * android device.
+ */
+enum AudioMicrophoneLocation : uint32_t {
+    UNKNOWN             = 0,
+    MAINBODY            = 1,
+    MAINBODY_MOVABLE    = 2,
+    PERIPHERAL          = 3,
+};
+
+/**
+ * Identifier to help group related microphones together
+ * e.g. microphone arrays should belong to the same group
+ */
+typedef int32_t AudioMicrophoneGroup;
+
+/**
+ * Enum with standard polar patterns of microphones
+ */
+enum AudioMicrophoneDirectionality : uint32_t {
+    UNKNOWN         = 0,
+    OMNI            = 1,
+    BI_DIRECTIONAL  = 2,
+    CARDIOID        = 3,
+    HYPER_CARDIOID  = 4,
+    SUPER_CARDIOID  = 5,
+};
+
+/**
+ * A (frequency, level) pair. Used to represent frequency response.
+ */
+struct AudioFrequencyResponsePoint {
+    /** In Hz */
+    float frequency;
+    /** In dB */
+    float level;
+};
+
+/**
+ * Structure used by the HAL to describe microphone's characteristics
+ * Used by StreamIn and Device
+ */
+struct MicrophoneInfo {
+    /** Unique alphanumeric id for microphone. Guaranteed to be the same
+     * even after rebooting.
+     */
+    string                                  deviceId;
+    /**
+     * Device specific information
+     */
+    DeviceAddress                           deviceAddress;
+    /** Each element of the vector must describe the channel with the same
+     *  index.
+     */
+    vec<AudioMicrophoneChannelMapping>      channelMapping;
+    /** Location of the microphone in regard to the body of the device */
+    AudioMicrophoneLocation                 location;
+    /** Identifier to help group related microphones together
+     *  e.g. microphone arrays should belong to the same group
+     */
+    AudioMicrophoneGroup                    group;
+    /** Index of this microphone within the group.
+     *  (group, index) must be unique within the same device.
+     */
+    uint32_t                                indexInTheGroup;
+    /** Level in dBFS produced by a 1000 Hz tone at 94 dB SPL */
+    float                                   sensitivity;
+    /** Level in dB of the max SPL supported at 1000 Hz */
+    float                                   maxSpl;
+    /** Level in dB of the min SPL supported at 1000 Hz */
+    float                                   minSpl;
+    /** Standard polar pattern of the microphone */
+    AudioMicrophoneDirectionality           directionality;
+    /** Vector with ordered frequency responses (from low to high frequencies)
+     *  with the frequency response of the microphone.
+     *  Levels are in dB, relative to level at 1000 Hz
+     */
+    vec<AudioFrequencyResponsePoint>        frequencyResponse;
+    /** Position of the microphone's capsule in meters, from the
+     *  bottom-left-back corner of the bounding box of device.
+     */
+    AudioMicrophoneCoordinate               position;
+    /** Normalized point to signal the main orientation of the microphone's
+     *  capsule. sqrt(x^2 + y^2 + z^2) = 1
+     */
+    AudioMicrophoneCoordinate               orientation;
+};
diff --git a/audio/README b/audio/README
index 1f1e8e3..abe979c 100644
--- a/audio/README
+++ b/audio/README
@@ -1,48 +1,33 @@
 Directory structure of the audio HIDL related code.
 
 audio
-|-- 2.0              <== HIDL (.hal) can not be moved to fit the directory structure
-|                        because that would create a separate HAL
+|-- 2.0              <== core 2.0 HIDL API. .hal can not be moved into the core directory
+|                        because that would change its namespace and include path
 |-- 4.0              <== Version 4.0 of the core API
 |
-|-- common           <== code common to audio core and effect API
-|   |-- 2.0
-|   |   |-- default  <== code that wraps the legacy API
-|   |   `-- vts      <== vts of 2.0 core and effect API common code
-|   |-- 4.0
-|   |   |-- default
-|   |   `-- vts
-|   |-- ...          <== The future versions should continue this structure
-|   |   |-- default
-|   |   `-- vts
-|   `-- all_versions <== code common to all version of both core and effect API
-|       |-- default
-|       `-- vts      <== vts of core and effect API common version independent code
+|-- ...
 |
-|-- core           <== code relative to the core API
-|   |-- 2.0          <== 2.0 core API code (except .hal, see audio/2.0)
-|   |   |-- default
-|   |   `-- vts
+|-- common           <== code common to audio core and effect API
+|   |-- 2.0          <== HIDL API of V2
 |   |-- 4.0
-|   |   |-- default  <== default implementation of the core 4.0 api
-|   |   `-- vts      <== vts code of the 4.0 API
 |   |-- ...
-|   |   |-- default
-|   |   `-- vts
-|   `-- all_versions
-|       |-- default
-|       `-- vts      <== vts of core API common version independent code
+|   `-- all_versions <== code common to all version of both core and effect API
+|       |-- default  <== implementation shared code between core and effect impl
+|       |-- test     <== utilities used by tests
+|       `-- util     <== utilities used by both implementation and tests
+|
+|-- core             <== VTS and default implementation of the core API (not HIDL, see /audio/2.0))
+|   `-- all_versions <== Code is version independent through #if and separate files
+|       |-- default  <== code that wraps the legacy API
+|       `-- vts      <== vts of core API
+|           |-- 2.0  <== 2.0 specific tests and helpers
+|           |-- 4.0
+|           |-- ...
 |
 `-- effect           <== idem for the effect API
     |-- 2.0
-    |   |-- default
-    |   `-- vts
     |-- 4.0
-    |   |-- default
-    |   `-- vts
     |-- ...
-    |   |-- default
-    |   `-- vts
     `-- all_versions
         |-- default
         `-- vts
diff --git a/audio/common/2.0/default/Android.bp b/audio/common/2.0/default/Android.bp
deleted file mode 100644
index ac66479..0000000
--- a/audio/common/2.0/default/Android.bp
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// 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.
-
-cc_library_shared {
-    name: "android.hardware.audio.common@2.0-util",
-    defaults: ["hidl_defaults"],
-    vendor_available: true,
-    vndk: {
-        enabled: true,
-    },
-    srcs: [
-        "HidlUtils.cpp",
-    ],
-
-    export_include_dirs: ["."],
-
-    static_libs: [
-    ],
-
-    shared_libs: [
-        "liblog",
-        "libutils",
-        "libhidlbase",
-        "android.hardware.audio.common-util",
-        "android.hardware.audio.common@2.0",
-    ],
-    export_shared_lib_headers: [
-        "android.hardware.audio.common-util"
-    ],
-
-    header_libs: [
-        "libaudio_system_headers",
-        "libhardware_headers",
-    ],
-}
diff --git a/audio/common/2.0/default/HidlUtils.cpp b/audio/common/2.0/default/HidlUtils.cpp
deleted file mode 100644
index 9771b7b..0000000
--- a/audio/common/2.0/default/HidlUtils.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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 "HidlUtils.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <common/all-versions/default/HidlUtils.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/common/2.0/default/HidlUtils.h b/audio/common/2.0/default/HidlUtils.h
deleted file mode 100644
index 24543b1..0000000
--- a/audio/common/2.0/default/HidlUtils.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef android_hardware_audio_V2_0_Hidl_Utils_H_
-#define android_hardware_audio_V2_0_Hidl_Utils_H_
-
-#include <android/hardware/audio/common/2.0/types.h>
-
-#define AUDIO_HAL_VERSION V2_0
-#include <common/all-versions/default/HidlUtils.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // android_hardware_audio_V2_0_Hidl_Utils_H_
diff --git a/audio/common/2.0/default/VersionUtils.h b/audio/common/2.0/default/VersionUtils.h
deleted file mode 100644
index 60d1f9c..0000000
--- a/audio/common/2.0/default/VersionUtils.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
-
-#include <android/hardware/audio/common/2.0/types.h>
-
-namespace android {
-namespace hardware {
-namespace audio {
-namespace common {
-namespace V2_0 {
-namespace implementation {
-
-typedef common::V2_0::AudioDevice AudioDeviceBitfield;
-typedef common::V2_0::AudioChannelMask AudioChannelBitfield;
-typedef common::V2_0::AudioOutputFlag AudioOutputFlagBitfield;
-typedef common::V2_0::AudioInputFlag AudioInputFlagBitfield;
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace common
-}  // namespace audio
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
diff --git a/audio/common/4.0/default/HidlUtils.cpp b/audio/common/4.0/default/HidlUtils.cpp
deleted file mode 100644
index b66eff9..0000000
--- a/audio/common/4.0/default/HidlUtils.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2018 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 "HidlUtils.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <common/all-versions/default/HidlUtils.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/common/4.0/default/OWNERS b/audio/common/4.0/default/OWNERS
deleted file mode 100644
index 6fdc97c..0000000
--- a/audio/common/4.0/default/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-elaurent@google.com
-krocard@google.com
-mnaganov@google.com
diff --git a/audio/common/4.0/default/VersionUtils.h b/audio/common/4.0/default/VersionUtils.h
deleted file mode 100644
index b7f2aec..0000000
--- a/audio/common/4.0/default/VersionUtils.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
-
-#include <android/hardware/audio/common/4.0/types.h>
-
-namespace android {
-namespace hardware {
-namespace audio {
-namespace common {
-namespace V4_0 {
-namespace implementation {
-
-typedef hidl_bitfield<common::V4_0::AudioDevice> AudioDeviceBitfield;
-typedef hidl_bitfield<common::V4_0::AudioChannelMask> AudioChannelBitfield;
-typedef hidl_bitfield<common::V4_0::AudioOutputFlag> AudioOutputFlagBitfield;
-typedef hidl_bitfield<common::V4_0::AudioInputFlag> AudioInputFlagBitfield;
-
-}  // namespace implementation
-}  // namespace V4_0
-}  // namespace common
-}  // namespace audio
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
diff --git a/audio/common/5.0/Android.bp b/audio/common/5.0/Android.bp
new file mode 100644
index 0000000..663f847
--- /dev/null
+++ b/audio/common/5.0/Android.bp
@@ -0,0 +1,48 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.audio.common@5.0",
+    root: "android.hardware",
+    vndk: {
+        enabled: true,
+    },
+    srcs: [
+        "types.hal",
+    ],
+    types: [
+        "AudioChannelMask",
+        "AudioConfig",
+        "AudioContentType",
+        "AudioDevice",
+        "AudioFormat",
+        "AudioGain",
+        "AudioGainConfig",
+        "AudioGainMode",
+        "AudioHandleConsts",
+        "AudioInputFlag",
+        "AudioMixLatencyClass",
+        "AudioMode",
+        "AudioOffloadInfo",
+        "AudioOutputFlag",
+        "AudioPort",
+        "AudioPortConfig",
+        "AudioPortConfigDeviceExt",
+        "AudioPortConfigMask",
+        "AudioPortConfigSessionExt",
+        "AudioPortDeviceExt",
+        "AudioPortMixExt",
+        "AudioPortRole",
+        "AudioPortSessionExt",
+        "AudioPortType",
+        "AudioSessionConsts",
+        "AudioSource",
+        "AudioStreamType",
+        "AudioUsage",
+        "FixedChannelCount",
+        "ThreadInfo",
+        "Uuid",
+    ],
+    gen_java: false,
+    gen_java_constants: true,
+}
+
diff --git a/audio/common/5.0/types.hal b/audio/common/5.0/types.hal
new file mode 100644
index 0000000..2ce2929
--- /dev/null
+++ b/audio/common/5.0/types.hal
@@ -0,0 +1,936 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.common@5.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
+ * hardware module.  But the same patch receives another system wide unique
+ * handle allocated by the framework.  This unique handle is used for all
+ * transactions inside the framework.
+ */
+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="")
+enum AudioHandleConsts : int32_t {
+    AUDIO_IO_HANDLE_NONE = 0,
+    AUDIO_MODULE_HANDLE_NONE = 0,
+    AUDIO_PORT_HANDLE_NONE = 0,
+    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.
+ */
+struct Uuid {
+    uint32_t timeLow;
+    uint16_t timeMid;
+    uint16_t versionAndTimeHigh;
+    uint16_t variantAndClockSeqHigh;
+    uint8_t[6] node;
+};
+
+
+/*
+ *
+ *  Audio streams
+ *
+ */
+
+/**
+ * Audio stream type describing the intended use case of a stream.
+ */
+@export(name="audio_stream_type_t", value_prefix="AUDIO_STREAM_")
+enum AudioStreamType : int32_t {
+    // These values must kept in sync with
+    //  frameworks/base/media/java/android/media/AudioSystem.java
+    DEFAULT          = -1,
+    MIN              = 0,
+    VOICE_CALL       = 0,
+    SYSTEM           = 1,
+    RING             = 2,
+    MUSIC            = 3,
+    ALARM            = 4,
+    NOTIFICATION     = 5,
+    BLUETOOTH_SCO    = 6,
+    ENFORCED_AUDIBLE = 7,  // Sounds that cannot be muted by user and must be
+                           // routed to speaker
+    DTMF             = 8,
+    TTS              = 9,  // Transmitted Through Speaker.  Plays over speaker
+                           // only, silent on other devices
+    ACCESSIBILITY    = 10, // For accessibility talk back prompts
+};
+
+@export(name="audio_source_t", value_prefix="AUDIO_SOURCE_")
+enum AudioSource : int32_t {
+    // These values must kept in sync with
+    //  frameworks/base/media/java/android/media/MediaRecorder.java,
+    //  frameworks/av/services/audiopolicy/AudioPolicyService.cpp,
+    //  system/media/audio_effects/include/audio_effects/audio_effects_conf.h
+    DEFAULT             = 0,
+    MIC                 = 1,
+    VOICE_UPLINK        = 2,
+    VOICE_DOWNLINK      = 3,
+    VOICE_CALL          = 4,
+    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.
+     */
+    UNPROCESSED         = 9,
+
+    FM_TUNER            = 1998,
+};
+
+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.
+     */
+    NONE = 0
+};
+
+/**
+ * Audio format  is a 32-bit word that consists of:
+ *   main format field (upper 8 bits)
+ *   sub format field (lower 24 bits).
+ *
+ * The main format indicates the main codec type. The sub format field indicates
+ * options and parameters for each format. The sub format is mainly used for
+ * record to indicate for instance the requested bitrate or profile.  It can
+ * also be used for certain formats to give informations not present in the
+ * encoded audio stream (e.g. octet alignement for AMR).
+ */
+@export(name="audio_format_t", value_prefix="AUDIO_FORMAT_")
+enum AudioFormat : uint32_t {
+    INVALID             = 0xFFFFFFFFUL,
+    DEFAULT             = 0,
+    PCM                 = 0x00000000UL,
+    MP3                 = 0x01000000UL,
+    AMR_NB              = 0x02000000UL,
+    AMR_WB              = 0x03000000UL,
+    AAC                 = 0x04000000UL,
+    /** Deprecated, Use AAC_HE_V1 */
+    HE_AAC_V1           = 0x05000000UL,
+    /** Deprecated, Use AAC_HE_V2 */
+    HE_AAC_V2           = 0x06000000UL,
+    VORBIS              = 0x07000000UL,
+    OPUS                = 0x08000000UL,
+    AC3                 = 0x09000000UL,
+    E_AC3               = 0x0A000000UL,
+    DTS                 = 0x0B000000UL,
+    DTS_HD              = 0x0C000000UL,
+    /** IEC61937 is encoded audio wrapped in 16-bit PCM. */
+    IEC61937            = 0x0D000000UL,
+    DOLBY_TRUEHD        = 0x0E000000UL,
+    EVRC                = 0x10000000UL,
+    EVRCB               = 0x11000000UL,
+    EVRCWB              = 0x12000000UL,
+    EVRCNW              = 0x13000000UL,
+    AAC_ADIF            = 0x14000000UL,
+    WMA                 = 0x15000000UL,
+    WMA_PRO             = 0x16000000UL,
+    AMR_WB_PLUS         = 0x17000000UL,
+    MP2                 = 0x18000000UL,
+    QCELP               = 0x19000000UL,
+    DSD                 = 0x1A000000UL,
+    FLAC                = 0x1B000000UL,
+    ALAC                = 0x1C000000UL,
+    APE                 = 0x1D000000UL,
+    AAC_ADTS            = 0x1E000000UL,
+    SBC                 = 0x1F000000UL,
+    APTX                = 0x20000000UL,
+    APTX_HD             = 0x21000000UL,
+    AC4                 = 0x22000000UL,
+    LDAC                = 0x23000000UL,
+    /** Dolby Metadata-enhanced Audio Transmission */
+    MAT                 = 0x24000000UL,
+    /** Deprecated */
+    MAIN_MASK           = 0xFF000000UL,
+    SUB_MASK            = 0x00FFFFFFUL,
+
+    /* 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
+    PCM_SUB_8_24_BIT      = 0x4, // PCM signed 8.23 fixed point
+    PCM_SUB_FLOAT         = 0x5, // PCM single-precision float pt
+    PCM_SUB_24_BIT_PACKED = 0x6, // PCM signed .23 fix pt (3 bytes)
+
+    MP3_SUB_NONE          = 0x0,
+
+    AMR_SUB_NONE          = 0x0,
+
+    AAC_SUB_MAIN          = 0x1,
+    AAC_SUB_LC            = 0x2,
+    AAC_SUB_SSR           = 0x4,
+    AAC_SUB_LTP           = 0x8,
+    AAC_SUB_HE_V1         = 0x10,
+    AAC_SUB_SCALABLE      = 0x20,
+    AAC_SUB_ERLC          = 0x40,
+    AAC_SUB_LD            = 0x80,
+    AAC_SUB_HE_V2         = 0x100,
+    AAC_SUB_ELD           = 0x200,
+    AAC_SUB_XHE           = 0x300,
+
+    VORBIS_SUB_NONE       = 0x0,
+
+    E_AC3_SUB_JOC         = 0x1,
+
+    MAT_SUB_1_0           = 0x1,
+    MAT_SUB_2_0           = 0x2,
+    MAT_SUB_2_1           = 0x3,
+
+    /* Aliases */
+    /** note != AudioFormat.ENCODING_PCM_16BIT */
+    PCM_16_BIT          = (PCM | PCM_SUB_16_BIT),
+    /** 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),
+    PCM_FLOAT           = (PCM | PCM_SUB_FLOAT),
+    PCM_24_BIT_PACKED   = (PCM | PCM_SUB_24_BIT_PACKED),
+    AAC_MAIN            = (AAC | AAC_SUB_MAIN),
+    AAC_LC              = (AAC | AAC_SUB_LC),
+    AAC_SSR             = (AAC | AAC_SUB_SSR),
+    AAC_LTP             = (AAC | AAC_SUB_LTP),
+    AAC_HE_V1           = (AAC | AAC_SUB_HE_V1),
+    AAC_SCALABLE        = (AAC | AAC_SUB_SCALABLE),
+    AAC_ERLC            = (AAC | AAC_SUB_ERLC),
+    AAC_LD              = (AAC | AAC_SUB_LD),
+    AAC_HE_V2           = (AAC | AAC_SUB_HE_V2),
+    AAC_ELD             = (AAC | AAC_SUB_ELD),
+    AAC_XHE             = (AAC | AAC_SUB_XHE),
+    AAC_ADTS_MAIN       = (AAC_ADTS | AAC_SUB_MAIN),
+    AAC_ADTS_LC         = (AAC_ADTS | AAC_SUB_LC),
+    AAC_ADTS_SSR        = (AAC_ADTS | AAC_SUB_SSR),
+    AAC_ADTS_LTP        = (AAC_ADTS | AAC_SUB_LTP),
+    AAC_ADTS_HE_V1      = (AAC_ADTS | AAC_SUB_HE_V1),
+    AAC_ADTS_SCALABLE   = (AAC_ADTS | AAC_SUB_SCALABLE),
+    AAC_ADTS_ERLC       = (AAC_ADTS | AAC_SUB_ERLC),
+    AAC_ADTS_LD         = (AAC_ADTS | AAC_SUB_LD),
+    AAC_ADTS_HE_V2      = (AAC_ADTS | AAC_SUB_HE_V2),
+    AAC_ADTS_ELD        = (AAC_ADTS | AAC_SUB_ELD),
+    AAC_ADTS_XHE        = (AAC_ADTS | AAC_SUB_XHE),
+    E_AC3_JOC           = (E_AC3 | E_AC3_SUB_JOC),
+    MAT_1_0             = (MAT | MAT_SUB_1_0),
+    MAT_2_0             = (MAT | MAT_SUB_2_0),
+    MAT_2_1             = (MAT | MAT_SUB_2_1),
+};
+
+/**
+ * Usage of these values highlights places in the code that use 2- or 8- channel
+ * assumptions.
+ */
+@export(name="")
+enum FixedChannelCount : int32_t {
+    FCC_2 = 2, // This is typically due to legacy implementation of stereo I/O
+    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.
+ *
+ * AudioChannelMask is an opaque type and its internal layout should not be
+ * assumed as it may change in the future.  Instead, always use functions
+ * to examine it.
+ *
+ * These are the current representations:
+ *
+ *   REPRESENTATION_POSITION
+ *     is a channel mask representation for position assignment.  Each low-order
+ *     bit corresponds to the spatial position of a transducer (output), or
+ *     interpretation of channel (input).  The user of a channel mask needs to
+ *     know the context of whether it is for output or input.  The constants
+ *     OUT_* or IN_* apply to the bits portion.  It is not permitted for no bits
+ *     to be set.
+ *
+ *   REPRESENTATION_INDEX
+ *     is a channel mask representation for index assignment.  Each low-order
+ *     bit corresponds to a selected channel.  There is no platform
+ *     interpretation of the various bits.  There is no concept of output or
+ *     input.  It is not permitted for no bits to be set.
+ *
+ * All other representations are reserved for future use.
+ *
+ * Warning: current representation distinguishes between input and output, but
+ * this will not the be case in future revisions of the platform. Wherever there
+ * is an ambiguity between input and output that is currently resolved by
+ * checking the channel mask, the implementer should look for ways to fix it
+ * with additional information outside of the mask.
+ */
+@export(name="", value_prefix="AUDIO_CHANNEL_")
+enum AudioChannelMask : uint32_t {
+    /** must be 0 for compatibility */
+    REPRESENTATION_POSITION = 0,
+    /** 1 is reserved for future use */
+    REPRESENTATION_INDEX    = 2,
+    /* 3 is reserved for future use */
+
+    /** 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 */
+    OUT_FRONT_LEFT            = 0x1,
+    OUT_FRONT_RIGHT           = 0x2,
+    OUT_FRONT_CENTER          = 0x4,
+    OUT_LOW_FREQUENCY         = 0x8,
+    OUT_BACK_LEFT             = 0x10,
+    OUT_BACK_RIGHT            = 0x20,
+    OUT_FRONT_LEFT_OF_CENTER  = 0x40,
+    OUT_FRONT_RIGHT_OF_CENTER = 0x80,
+    OUT_BACK_CENTER           = 0x100,
+    OUT_SIDE_LEFT             = 0x200,
+    OUT_SIDE_RIGHT            = 0x400,
+    OUT_TOP_CENTER            = 0x800,
+    OUT_TOP_FRONT_LEFT        = 0x1000,
+    OUT_TOP_FRONT_CENTER      = 0x2000,
+    OUT_TOP_FRONT_RIGHT       = 0x4000,
+    OUT_TOP_BACK_LEFT         = 0x8000,
+    OUT_TOP_BACK_CENTER       = 0x10000,
+    OUT_TOP_BACK_RIGHT        = 0x20000,
+    OUT_TOP_SIDE_LEFT         = 0x40000,
+    OUT_TOP_SIDE_RIGHT        = 0x80000,
+
+    OUT_MONO     = OUT_FRONT_LEFT,
+    OUT_STEREO   = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT),
+    OUT_2POINT1  = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_LOW_FREQUENCY),
+    OUT_2POINT0POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+                         OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
+    OUT_2POINT1POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+                         OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT |
+                         OUT_LOW_FREQUENCY),
+    OUT_3POINT0POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT |
+                         OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
+    OUT_3POINT1POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT |
+                        OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT |
+                        OUT_LOW_FREQUENCY),
+    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_* */
+    OUT_QUAD_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+            OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
+    OUT_SURROUND = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+            OUT_FRONT_CENTER | OUT_BACK_CENTER),
+    OUT_PENTA = (OUT_QUAD | OUT_FRONT_CENTER),
+    OUT_5POINT1   = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+            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_* */
+    OUT_5POINT1_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+            OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
+            OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
+    OUT_5POINT1POINT2  = (OUT_5POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
+    OUT_5POINT1POINT4  = (OUT_5POINT1 |
+            OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT |
+            OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT),
+    OUT_6POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+            OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
+            OUT_BACK_LEFT | OUT_BACK_RIGHT |
+            OUT_BACK_CENTER),
+    /** 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 |
+            OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
+    OUT_7POINT1POINT2  = (OUT_7POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
+    OUT_7POINT1POINT4  = (OUT_7POINT1 |
+            OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT |
+            OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT),
+    // Note that the 2.0 OUT_ALL* have been moved to helper functions
+
+    /* These are bits only, not complete values */
+
+    /** input channels */
+    IN_LEFT            = 0x4,
+    IN_RIGHT           = 0x8,
+    IN_FRONT           = 0x10,
+    IN_BACK            = 0x20,
+    IN_LEFT_PROCESSED  = 0x40,
+    IN_RIGHT_PROCESSED = 0x80,
+    IN_FRONT_PROCESSED = 0x100,
+    IN_BACK_PROCESSED  = 0x200,
+    IN_PRESSURE        = 0x400,
+    IN_X_AXIS          = 0x800,
+    IN_Y_AXIS          = 0x1000,
+    IN_Z_AXIS          = 0x2000,
+    IN_BACK_LEFT       = 0x10000,
+    IN_BACK_RIGHT      = 0x20000,
+    IN_CENTER          = 0x40000,
+    IN_LOW_FREQUENCY   = 0x100000,
+    IN_TOP_LEFT        = 0x200000,
+    IN_TOP_RIGHT       = 0x400000,
+
+    IN_VOICE_UPLINK    = 0x4000,
+    IN_VOICE_DNLINK    = 0x8000,
+
+    IN_MONO   = IN_FRONT,
+    IN_STEREO = (IN_LEFT | IN_RIGHT),
+    IN_FRONT_BACK = (IN_FRONT | IN_BACK),
+    IN_6 = (IN_LEFT | IN_RIGHT |
+            IN_FRONT | IN_BACK |
+            IN_LEFT_PROCESSED | IN_RIGHT_PROCESSED),
+    IN_2POINT0POINT2 = (IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT),
+    IN_2POINT1POINT2 = (IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT |
+            IN_LOW_FREQUENCY),
+    IN_3POINT0POINT2 = (IN_LEFT | IN_CENTER | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT),
+    IN_3POINT1POINT2 = (IN_LEFT | IN_CENTER | IN_RIGHT |
+            IN_TOP_LEFT | IN_TOP_RIGHT | IN_LOW_FREQUENCY),
+    IN_5POINT1 = (IN_LEFT | IN_CENTER | IN_RIGHT |
+                  IN_BACK_LEFT | IN_BACK_RIGHT | IN_LOW_FREQUENCY),
+    IN_VOICE_UPLINK_MONO = (IN_VOICE_UPLINK | IN_MONO),
+    IN_VOICE_DNLINK_MONO = (IN_VOICE_DNLINK | IN_MONO),
+    IN_VOICE_CALL_MONO   = (IN_VOICE_UPLINK_MONO |
+            IN_VOICE_DNLINK_MONO),
+    // Note that the 2.0 IN_ALL* have been moved to helper functions
+
+    COUNT_MAX    = 30,
+    INDEX_HDR    = REPRESENTATION_INDEX << COUNT_MAX,
+    INDEX_MASK_1 = INDEX_HDR | ((1 << 1) - 1),
+    INDEX_MASK_2 = INDEX_HDR | ((1 << 2) - 1),
+    INDEX_MASK_3 = INDEX_HDR | ((1 << 3) - 1),
+    INDEX_MASK_4 = INDEX_HDR | ((1 << 4) - 1),
+    INDEX_MASK_5 = INDEX_HDR | ((1 << 5) - 1),
+    INDEX_MASK_6 = INDEX_HDR | ((1 << 6) - 1),
+    INDEX_MASK_7 = INDEX_HDR | ((1 << 7) - 1),
+    INDEX_MASK_8 = INDEX_HDR | ((1 << 8) - 1)
+};
+
+/**
+ * Major modes for a mobile device. The current mode setting affects audio
+ * routing.
+ */
+@export(name="audio_mode_t", value_prefix="AUDIO_MODE_")
+enum AudioMode : int32_t {
+    NORMAL           = 0,
+    RINGTONE         = 1,
+    /** Calls handled by the telephony stack (Eg: PSTN). */
+    IN_CALL          = 2,
+    /** Calls handled by apps (Eg: Hangout). */
+    IN_COMMUNICATION = 3,
+};
+
+@export(name="", value_prefix="AUDIO_DEVICE_")
+enum AudioDevice : uint32_t {
+    NONE                          = 0x0,
+    /** reserved bits */
+    BIT_IN                        = 0x80000000,
+    BIT_DEFAULT                   = 0x40000000,
+    /** output devices */
+    OUT_EARPIECE                  = 0x1,
+    OUT_SPEAKER                   = 0x2,
+    OUT_WIRED_HEADSET             = 0x4,
+    OUT_WIRED_HEADPHONE           = 0x8,
+    OUT_BLUETOOTH_SCO             = 0x10,
+    OUT_BLUETOOTH_SCO_HEADSET     = 0x20,
+    OUT_BLUETOOTH_SCO_CARKIT      = 0x40,
+    OUT_BLUETOOTH_A2DP            = 0x80,
+    OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
+    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) */
+    OUT_ANLG_DOCK_HEADSET         = 0x800,
+    OUT_DGTL_DOCK_HEADSET         = 0x1000,
+    /** 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 */
+    OUT_USB_DEVICE                = 0x4000,
+    OUT_REMOTE_SUBMIX             = 0x8000,
+    /** Telephony voice TX path */
+    OUT_TELEPHONY_TX              = 0x10000,
+    /** Analog jack with line impedance detected */
+    OUT_LINE                      = 0x20000,
+    /** HDMI Audio Return Channel */
+    OUT_HDMI_ARC                  = 0x40000,
+    /** S/PDIF out */
+    OUT_SPDIF                     = 0x80000,
+    /** FM transmitter out */
+    OUT_FM                        = 0x100000,
+    /** Line out for av devices */
+    OUT_AUX_LINE                  = 0x200000,
+    /** 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) */
+    OUT_BUS                       = 0x1000000,
+    OUT_PROXY                     = 0x2000000,
+    OUT_USB_HEADSET               = 0x4000000,
+    OUT_HEARING_AID               = 0x8000000,
+    OUT_ECHO_CANCELLER            = 0x10000000,
+    OUT_DEFAULT                   = BIT_DEFAULT,
+    // Note that the 2.0 OUT_ALL* have been moved to helper functions
+
+    /** input devices */
+    IN_COMMUNICATION         = BIT_IN | 0x1,
+    IN_AMBIENT               = BIT_IN | 0x2,
+    IN_BUILTIN_MIC           = BIT_IN | 0x4,
+    IN_BLUETOOTH_SCO_HEADSET = BIT_IN | 0x8,
+    IN_WIRED_HEADSET         = BIT_IN | 0x10,
+    IN_AUX_DIGITAL           = BIT_IN | 0x20,
+    IN_HDMI                  = IN_AUX_DIGITAL,
+    /** Telephony voice RX path */
+    IN_VOICE_CALL            = BIT_IN | 0x40,
+    IN_TELEPHONY_RX          = IN_VOICE_CALL,
+    IN_BACK_MIC              = BIT_IN | 0x80,
+    IN_REMOTE_SUBMIX         = BIT_IN | 0x100,
+    IN_ANLG_DOCK_HEADSET     = BIT_IN | 0x200,
+    IN_DGTL_DOCK_HEADSET     = BIT_IN | 0x400,
+    IN_USB_ACCESSORY         = BIT_IN | 0x800,
+    IN_USB_DEVICE            = BIT_IN | 0x1000,
+    /** FM tuner input */
+    IN_FM_TUNER              = BIT_IN | 0x2000,
+    /** TV tuner input */
+    IN_TV_TUNER              = BIT_IN | 0x4000,
+    /** Analog jack with line impedance detected */
+    IN_LINE                  = BIT_IN | 0x8000,
+    /** 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) */
+    IN_BUS                   = BIT_IN | 0x100000,
+    IN_PROXY                 = BIT_IN | 0x1000000,
+    IN_USB_HEADSET           = BIT_IN | 0x2000000,
+    IN_BLUETOOTH_BLE         = BIT_IN | 0x4000000,
+    IN_DEFAULT               = BIT_IN | BIT_DEFAULT,
+
+    // Note that the 2.0 IN_ALL* have been moved to helper functions
+};
+
+/**
+ * The audio output flags serve two purposes:
+ *
+ *  - when an AudioTrack is created they indicate a "wish" to be connected to an
+ *    output stream with attributes corresponding to the specified flags;
+ *
+ *  - when present in an output profile descriptor listed for a particular audio
+ *    hardware module, they indicate that an output stream can be opened that
+ *    supports the attributes indicated by the flags.
+ *
+ * The audio policy manager will try to match the flags in the request
+ * (when getOuput() is called) to an available output stream.
+ */
+@export(name="audio_output_flags_t", value_prefix="AUDIO_OUTPUT_FLAG_")
+enum AudioOutputFlag : int32_t {
+    NONE    = 0x0, // no attributes
+    DIRECT  = 0x1, // this output directly connects a track
+                   // to one output stream: no software mixer
+    PRIMARY = 0x2, // this output is the primary output of the device. It is
+                   // unique and must be present. It is opened by default and
+                   // receives routing, audio mode and volume controls related
+                   // to voice calls.
+    FAST    = 0x4,    // output supports "fast tracks", defined elsewhere
+    DEEP_BUFFER      = 0x8,   // use deep audio buffers
+    COMPRESS_OFFLOAD = 0x10,  // offload playback of compressed streams to
+                              // hardware codec
+    NON_BLOCKING     = 0x20,  // use non-blocking write
+    HW_AV_SYNC = 0x40,   // output uses a hardware A/V sync
+    TTS        = 0x80,   // output for streams transmitted through speaker at a
+                         // sample rate high enough to accommodate lower-range
+                         // ultrasonic p/b
+    RAW        = 0x100,  // minimize signal processing
+    SYNC       = 0x200,  // synchronize I/O streams
+    IEC958_NONAUDIO = 0x400, // Audio stream contains compressed audio in SPDIF
+                             // data bursts, not PCM.
+    DIRECT_PCM = 0x2000,     // Audio stream containing PCM data that needs
+                             // to pass through compress path for DSP post proc.
+    MMAP_NOIRQ = 0x4000, // output operates in MMAP no IRQ mode.
+    VOIP_RX = 0x8000,    // preferred output for VoIP calls.
+    /** preferred output for call music */
+    INCALL_MUSIC = 0x10000,
+};
+
+/**
+ * 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
+ * attributes corresponding to the specified flags.
+ */
+@export(name="audio_input_flags_t", value_prefix="AUDIO_INPUT_FLAG_")
+enum AudioInputFlag : int32_t {
+    NONE         = 0x0,  // no attributes
+    FAST         = 0x1,  // prefer an input that supports "fast tracks"
+    HW_HOTWORD   = 0x2,  // prefer an input that captures from hw hotword source
+    RAW          = 0x4,  // minimize signal processing
+    SYNC         = 0x8,  // synchronize I/O streams
+    MMAP_NOIRQ   = 0x10, // input operates in MMAP no IRQ mode.
+    VOIP_TX      = 0x20, // preferred input for VoIP calls.
+    HW_AV_SYNC   = 0x40, // input connected to an output that uses a hardware A/V sync
+};
+
+@export(name="audio_usage_t", value_prefix="AUDIO_USAGE_")
+enum AudioUsage : int32_t {
+    // These values must kept in sync with
+    //  frameworks/base/media/java/android/media/AudioAttributes.java
+    // Note that not all framework values are exposed
+    UNKNOWN                            = 0,
+    MEDIA                              = 1,
+    VOICE_COMMUNICATION                = 2,
+    VOICE_COMMUNICATION_SIGNALLING     = 3,
+    ALARM                              = 4,
+    NOTIFICATION                       = 5,
+    NOTIFICATION_TELEPHONY_RINGTONE    = 6,
+    ASSISTANCE_ACCESSIBILITY           = 11,
+    ASSISTANCE_NAVIGATION_GUIDANCE     = 12,
+    ASSISTANCE_SONIFICATION            = 13,
+    GAME                               = 14,
+    VIRTUAL_SOURCE                     = 15,
+    ASSISTANT                          = 16,
+};
+
+/** Type of audio generated by an application. */
+@export(name="audio_content_type_t", value_prefix="AUDIO_CONTENT_TYPE_")
+enum AudioContentType : uint32_t {
+    // Do not change these values without updating their counterparts
+    // in frameworks/base/media/java/android/media/AudioAttributes.java
+    UNKNOWN      = 0,
+    SPEECH       = 1,
+    MUSIC        = 2,
+    MOVIE        = 3,
+    SONIFICATION = 4,
+};
+
+/**
+ * Additional information about the stream passed to hardware decoders.
+ */
+struct AudioOffloadInfo {
+    uint32_t sampleRateHz;
+    bitfield<AudioChannelMask> channelMask;
+    AudioFormat format;
+    AudioStreamType streamType;
+    uint32_t bitRatePerSecond;
+    int64_t durationMicroseconds;  // -1 if unknown
+    bool hasVideo;
+    bool isStreaming;
+    uint32_t bitWidth;
+    uint32_t bufferSize;
+    AudioUsage usage;
+};
+
+/**
+ * Commonly used audio stream configuration parameters.
+ */
+struct AudioConfig {
+    uint32_t sampleRateHz;
+    bitfield<AudioChannelMask> channelMask;
+    AudioFormat format;
+    AudioOffloadInfo offloadInfo;
+    uint64_t frameCount;
+};
+
+/** Metadata of a playback track for a StreamOut. */
+struct PlaybackTrackMetadata {
+    AudioUsage usage;
+    AudioContentType contentType;
+    /**
+     * Positive linear gain applied to the track samples. 0 being muted and 1 is no attenuation,
+     * 2 means double amplification...
+     * Must not be negative.
+     */
+    float gain;
+};
+
+/** Metadatas of the source of a StreamOut. */
+struct SourceMetadata {
+    vec<PlaybackTrackMetadata> tracks;
+};
+
+/** Metadata of a record track for a StreamIn. */
+struct RecordTrackMetadata {
+    AudioSource source;
+    /**
+     * Positive linear gain applied to the track samples. 0 being muted and 1 is no attenuation,
+     * 2 means double amplification...
+     * Must not be negative.
+     */
+    float gain;
+};
+
+/** Metadatas of the source of a StreamIn. */
+struct SinkMetadata {
+    vec<RecordTrackMetadata> tracks;
+};
+
+
+/*
+ *
+ *  Volume control
+ *
+ */
+
+/**
+ * Type of gain control exposed by an audio port.
+ */
+@export(name="", value_prefix="AUDIO_GAIN_MODE_")
+enum AudioGainMode : uint32_t {
+    JOINT = 0x1,    // supports joint channel gain control
+    CHANNELS = 0x2, // supports separate channel gain control
+    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.
+ */
+struct AudioGain {
+    bitfield<AudioGainMode> mode;
+    bitfield<AudioChannelMask> channelMask; // channels which gain an be controlled
+    int32_t minValue;     // minimum gain value in millibels
+    int32_t maxValue;     // maximum gain value in millibels
+    int32_t defaultValue; // default gain value in millibels
+    uint32_t stepValue;   // gain step in millibels
+    uint32_t minRampMs;   // minimum ramp duration in ms
+    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.
+ */
+struct AudioGainConfig {
+    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
+     * channel mask. The number of values is 1 in joint mode or
+     * popcount(channel_mask).
+     */
+    int32_t[4 * 8] values;
+    uint32_t rampDurationMs;  // ramp duration in ms
+};
+
+
+/*
+ *
+ *  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
+ * audio end point at the edge of the system managed by the module exposing
+ * the interface.
+ */
+
+/** Audio port role: either source or sink */
+@export(name="audio_port_role_t", value_prefix="AUDIO_PORT_ROLE_")
+enum AudioPortRole : int32_t {
+    NONE,
+    SOURCE,
+    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)
+ */
+@export(name="audio_port_type_t", value_prefix="AUDIO_PORT_TYPE_")
+enum AudioPortType : int32_t {
+    NONE,
+    DEVICE,
+    MIX,
+    SESSION,
+};
+
+/**
+ * Extension for audio port configuration structure when the audio port is a
+ * hardware device.
+ */
+struct AudioPortConfigDeviceExt {
+    AudioModuleHandle hwModule;  // module the device is attached to
+    AudioDevice type;            // device type (e.g OUT_SPEAKER)
+    uint8_t[32] address;         // device address. "" if N/A
+};
+
+/**
+ * Extension for audio port configuration structure when the audio port is an
+ * audio session.
+ */
+struct AudioPortConfigSessionExt {
+    AudioSession session;
+};
+
+/**
+ * Flags indicating which fields are to be considered in AudioPortConfig.
+ */
+@export(name="", value_prefix="AUDIO_PORT_CONFIG_")
+enum AudioPortConfigMask : uint32_t {
+    SAMPLE_RATE = 0x1,
+    CHANNEL_MASK =  0x2,
+    FORMAT = 0x4,
+    GAIN = 0x8,
+};
+
+/**
+ * Audio port configuration structure used to specify a particular configuration
+ * of an audio port.
+ */
+struct AudioPortConfig {
+    AudioPortHandle id;
+    bitfield<AudioPortConfigMask> configMask;
+    uint32_t sampleRateHz;
+    bitfield<AudioChannelMask> channelMask;
+    AudioFormat format;
+    AudioGainConfig gain;
+    AudioPortType type;  // type is used as a discriminator for Ext union
+    AudioPortRole role;  // role is used as a discriminator for UseCase union
+    union Ext {
+        AudioPortConfigDeviceExt device;
+        struct AudioPortConfigMixExt {
+            AudioModuleHandle hwModule; // module the stream is attached to
+            AudioIoHandle ioHandle;     // I/O handle of the input/output stream
+            union UseCase {
+                AudioStreamType stream;
+                AudioSource source;
+            } useCase;
+        } mix;
+        AudioPortConfigSessionExt session;
+    } ext;
+};
+
+/**
+ * Extension for audio port structure when the audio port is a hardware device.
+ */
+struct AudioPortDeviceExt {
+    AudioModuleHandle hwModule;    // module the device is attached to
+    AudioDevice type;
+    /** 32 byte string identifying the port. */
+    uint8_t[32] address;
+};
+
+/**
+ * Latency class of the audio mix.
+ */
+@export(name="audio_mix_latency_class_t", value_prefix="AUDIO_LATENCY_")
+enum AudioMixLatencyClass : int32_t {
+    LOW,
+    NORMAL
+};
+
+struct AudioPortMixExt {
+    AudioModuleHandle hwModule;     // module the stream is attached to
+    AudioIoHandle ioHandle;         // I/O handle of the stream
+    AudioMixLatencyClass latencyClass;
+};
+
+/**
+ * Extension for audio port structure when the audio port is an audio session.
+ */
+struct AudioPortSessionExt {
+    AudioSession session;
+};
+
+struct AudioPort {
+    AudioPortHandle id;
+    AudioPortRole role;
+    string name;
+    vec<uint32_t> sampleRates;
+    vec<bitfield<AudioChannelMask>> channelMasks;
+    vec<AudioFormat> formats;
+    vec<AudioGain> gains;
+    AudioPortConfig activeConfig; // current audio port configuration
+    AudioPortType type;  // type is used as a discriminator
+    union Ext {
+        AudioPortDeviceExt device;
+        AudioPortMixExt mix;
+        AudioPortSessionExt session;
+    } ext;
+};
+
+struct ThreadInfo {
+    int64_t pid;
+    int64_t tid;
+};
diff --git a/audio/common/all-versions/default/Android.bp b/audio/common/all-versions/default/Android.bp
index 4a27bb7..c0bd34c 100644
--- a/audio/common/all-versions/default/Android.bp
+++ b/audio/common/all-versions/default/Android.bp
@@ -17,9 +17,6 @@
     name: "android.hardware.audio.common-util",
     defaults: ["hidl_defaults"],
     vendor_available: true,
-    vndk: {
-        enabled: true,
-    },
     srcs: [
         "EffectMap.cpp",
     ],
@@ -41,3 +38,72 @@
         "android.hardware.audio.common.util@all-versions",
     ]
 }
+
+cc_defaults {
+    name: "android.hardware.audio.common-util_default",
+    defaults: ["hidl_defaults"],
+
+    vendor_available: true,
+    srcs: [
+        "HidlUtils.cpp",
+    ],
+
+    export_include_dirs: ["."],
+
+    shared_libs: [
+        "liblog",
+        "libutils",
+        "libhidlbase",
+        "android.hardware.audio.common-util",
+    ],
+    export_shared_lib_headers: [
+        "android.hardware.audio.common-util"
+    ],
+
+    header_libs: [
+        "libaudio_system_headers",
+        "libhardware_headers",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.audio.common@2.0-util",
+    defaults: ["android.hardware.audio.common-util_default"],
+
+    shared_libs: [
+        "android.hardware.audio.common@2.0",
+    ],
+    cflags: [
+        "-DMAJOR_VERSION=2",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
+
+cc_library_shared {
+    name: "android.hardware.audio.common@4.0-util",
+    defaults: ["android.hardware.audio.common-util_default"],
+
+    shared_libs: [
+        "android.hardware.audio.common@4.0",
+    ],
+    cflags: [
+        "-DMAJOR_VERSION=4",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
+
+cc_library_shared {
+    name: "android.hardware.audio.common@5.0-util",
+    defaults: ["android.hardware.audio.common-util_default"],
+
+    shared_libs: [
+        "android.hardware.audio.common@5.0",
+    ],
+    cflags: [
+        "-DMAJOR_VERSION=5",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
diff --git a/audio/common/all-versions/default/EffectMap.cpp b/audio/common/all-versions/default/EffectMap.cpp
index 7f8da1e..cb3e3d5 100644
--- a/audio/common/all-versions/default/EffectMap.cpp
+++ b/audio/common/all-versions/default/EffectMap.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h b/audio/common/all-versions/default/HidlUtils.cpp
similarity index 88%
rename from audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h
rename to audio/common/all-versions/default/HidlUtils.cpp
index 632e816..5ed059c 100644
--- a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h
+++ b/audio/common/all-versions/default/HidlUtils.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,36 +14,34 @@
  * limitations under the License.
  */
 
-#ifndef AUDIO_HAL_VERSION
-#error "AUDIO_HAL_VERSION must be set before including this file."
-#endif
+#include "HidlUtils.h"
 
 #include <common/all-versions/VersionUtils.h>
 #include <string.h>
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioGainMode;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMixLatencyClass;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfigMask;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortRole;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortType;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioStreamType;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioUsage;
+using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioFormat;
+using ::android::hardware::audio::common::CPP_VERSION::AudioGainMode;
+using ::android::hardware::audio::common::CPP_VERSION::AudioMixLatencyClass;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfigMask;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPortRole;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPortType;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::common::CPP_VERSION::AudioStreamType;
+using ::android::hardware::audio::common::CPP_VERSION::AudioUsage;
 
-using ::android::hardware::audio::common::utils::mkEnumConverter;
+using ::android::hardware::audio::common::utils::EnumBitfield;
 
 namespace android {
 namespace hardware {
 namespace audio {
 namespace common {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 
 void HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) {
     config->sampleRateHz = halConfig.sample_rate;
-    config->channelMask = mkEnumConverter<AudioChannelMask>(halConfig.channel_mask);
+    config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask);
     config->format = AudioFormat(halConfig.format);
     audioOffloadInfoFromHal(halConfig.offload_info, &config->offloadInfo);
     config->frameCount = halConfig.frame_count;
@@ -61,8 +59,8 @@
 void HidlUtils::audioGainConfigFromHal(const struct audio_gain_config& halConfig,
                                        AudioGainConfig* config) {
     config->index = halConfig.index;
-    config->mode = mkEnumConverter<AudioGainMode>(halConfig.mode);
-    config->channelMask = mkEnumConverter<AudioChannelMask>(halConfig.channel_mask);
+    config->mode = EnumBitfield<AudioGainMode>(halConfig.mode);
+    config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask);
     for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) {
         config->values[i] = halConfig.values[i];
     }
@@ -82,8 +80,8 @@
 }
 
 void HidlUtils::audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain) {
-    gain->mode = mkEnumConverter<AudioGainMode>(halGain.mode);
-    gain->channelMask = mkEnumConverter<AudioChannelMask>(halGain.channel_mask);
+    gain->mode = EnumBitfield<AudioGainMode>(halGain.mode);
+    gain->channelMask = EnumBitfield<AudioChannelMask>(halGain.channel_mask);
     gain->minValue = halGain.min_value;
     gain->maxValue = halGain.max_value;
     gain->defaultValue = halGain.default_value;
@@ -122,7 +120,7 @@
 void HidlUtils::audioOffloadInfoFromHal(const audio_offload_info_t& halOffload,
                                         AudioOffloadInfo* offload) {
     offload->sampleRateHz = halOffload.sample_rate;
-    offload->channelMask = mkEnumConverter<AudioChannelMask>(halOffload.channel_mask);
+    offload->channelMask = EnumBitfield<AudioChannelMask>(halOffload.channel_mask);
     offload->format = AudioFormat(halOffload.format);
     offload->streamType = AudioStreamType(halOffload.stream_type);
     offload->bitRatePerSecond = halOffload.bit_rate;
@@ -155,9 +153,9 @@
     config->id = halConfig.id;
     config->role = AudioPortRole(halConfig.role);
     config->type = AudioPortType(halConfig.type);
-    config->configMask = mkEnumConverter<AudioPortConfigMask>(halConfig.config_mask);
+    config->configMask = EnumBitfield<AudioPortConfigMask>(halConfig.config_mask);
     config->sampleRateHz = halConfig.sample_rate;
-    config->channelMask = mkEnumConverter<AudioChannelMask>(halConfig.channel_mask);
+    config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask);
     config->format = AudioFormat(halConfig.format);
     audioGainConfigFromHal(halConfig.gain, &config->gain);
     switch (halConfig.type) {
@@ -257,7 +255,7 @@
     }
     port->channelMasks.resize(halPort.num_channel_masks);
     for (size_t i = 0; i < halPort.num_channel_masks; ++i) {
-        port->channelMasks[i] = mkEnumConverter<AudioChannelMask>(halPort.channel_masks[i]);
+        port->channelMasks[i] = EnumBitfield<AudioChannelMask>(halPort.channel_masks[i]);
     }
     port->formats.resize(halPort.num_formats);
     for (size_t i = 0; i < halPort.num_formats; ++i) {
@@ -358,7 +356,7 @@
     memcpy(halUuid->node, uuid.node.data(), uuid.node.size());
 }
 
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace common
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h b/audio/common/all-versions/default/HidlUtils.h
similarity index 78%
rename from audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h
rename to audio/common/all-versions/default/HidlUtils.h
index f9a5697..77c8b89 100644
--- a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h
+++ b/audio/common/all-versions/default/HidlUtils.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,28 +14,29 @@
  * limitations under the License.
  */
 
-#ifndef AUDIO_HAL_VERSION
-#error "AUDIO_HAL_VERSION must be set before including this file."
-#endif
+#ifndef android_hardware_audio_Hidl_Utils_H_
+#define android_hardware_audio_Hidl_Utils_H_
+
+#include PATH(android/hardware/audio/common/FILE_VERSION/types.h)
 
 #include <memory>
 
 #include <system/audio.h>
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioConfig;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioGain;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioGainConfig;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioOffloadInfo;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPort;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfig;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::Uuid;
 using ::android::hardware::hidl_vec;
+using ::android::hardware::audio::common::CPP_VERSION::AudioConfig;
+using ::android::hardware::audio::common::CPP_VERSION::AudioGain;
+using ::android::hardware::audio::common::CPP_VERSION::AudioGainConfig;
+using ::android::hardware::audio::common::CPP_VERSION::AudioOffloadInfo;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPort;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfig;
+using ::android::hardware::audio::common::CPP_VERSION::Uuid;
 
 namespace android {
 namespace hardware {
 namespace audio {
 namespace common {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 
 class HidlUtils {
    public:
@@ -68,8 +69,10 @@
     static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid);
 };
 
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace common
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // android_hardware_audio_Hidl_Utils_H_
diff --git a/audio/common/2.0/default/OWNERS b/audio/common/all-versions/default/OWNERS
similarity index 100%
rename from audio/common/2.0/default/OWNERS
rename to audio/common/all-versions/default/OWNERS
diff --git a/audio/common/all-versions/default/VersionUtils.h b/audio/common/all-versions/default/VersionUtils.h
new file mode 100644
index 0000000..e7755b1
--- /dev/null
+++ b/audio/common/all-versions/default/VersionUtils.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
+
+#include PATH(android/hardware/audio/common/FILE_VERSION/types.h)
+
+namespace android {
+namespace hardware {
+namespace audio {
+namespace common {
+namespace CPP_VERSION {
+namespace implementation {
+
+#if MAJOR_VERSION == 2
+typedef common::CPP_VERSION::AudioDevice AudioDeviceBitfield;
+typedef common::CPP_VERSION::AudioChannelMask AudioChannelBitfield;
+typedef common::CPP_VERSION::AudioOutputFlag AudioOutputFlagBitfield;
+typedef common::CPP_VERSION::AudioInputFlag AudioInputFlagBitfield;
+#elif MAJOR_VERSION >= 4
+typedef hidl_bitfield<common::CPP_VERSION::AudioDevice> AudioDeviceBitfield;
+typedef hidl_bitfield<common::CPP_VERSION::AudioChannelMask> AudioChannelBitfield;
+typedef hidl_bitfield<common::CPP_VERSION::AudioOutputFlag> AudioOutputFlagBitfield;
+typedef hidl_bitfield<common::CPP_VERSION::AudioInputFlag> AudioInputFlagBitfield;
+#endif
+
+}  // namespace implementation
+}  // namespace CPP_VERSION
+}  // namespace common
+}  // namespace audio
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
diff --git a/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h b/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h
index 547c6d5..7f630bf 100644
--- a/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h
+++ b/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/default/service/Android.mk b/audio/common/all-versions/default/service/Android.mk
index 84de75e..32110ee 100644
--- a/audio/common/all-versions/default/service/Android.mk
+++ b/audio/common/all-versions/default/service/Android.mk
@@ -41,10 +41,13 @@
     libhwbinder \
     android.hardware.audio@2.0 \
     android.hardware.audio@4.0 \
+    android.hardware.audio@5.0 \
     android.hardware.audio.common@2.0 \
     android.hardware.audio.common@4.0 \
+    android.hardware.audio.common@5.0 \
     android.hardware.audio.effect@2.0 \
     android.hardware.audio.effect@4.0 \
+    android.hardware.audio.effect@5.0 \
     android.hardware.bluetooth.a2dp@1.0 \
     android.hardware.soundtrigger@2.0 \
     android.hardware.soundtrigger@2.1
@@ -57,7 +60,4 @@
 LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
 endif
 
-# b/117506164
-LOCAL_SANITIZE := never
-
 include $(BUILD_EXECUTABLE)
diff --git a/audio/common/all-versions/default/service/service.cpp b/audio/common/all-versions/default/service/service.cpp
index ff1394e..7b5da81 100644
--- a/audio/common/all-versions/default/service/service.cpp
+++ b/audio/common/all-versions/default/service/service.cpp
@@ -18,8 +18,10 @@
 
 #include <android/hardware/audio/2.0/IDevicesFactory.h>
 #include <android/hardware/audio/4.0/IDevicesFactory.h>
+#include <android/hardware/audio/5.0/IDevicesFactory.h>
 #include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
 #include <android/hardware/audio/effect/4.0/IEffectsFactory.h>
+#include <android/hardware/audio/effect/5.0/IEffectsFactory.h>
 #include <android/hardware/bluetooth/a2dp/1.0/IBluetoothAudioOffload.h>
 #include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
 #include <android/hardware/soundtrigger/2.1/ISoundTriggerHw.h>
@@ -46,13 +48,15 @@
     }
     configureRpcThreadpool(16, true /*callerWillJoin*/);
 
-    bool fail = registerPassthroughServiceImplementation<audio::V4_0::IDevicesFactory>() != OK &&
+    bool fail = registerPassthroughServiceImplementation<audio::V5_0::IDevicesFactory>() != OK &&
+                registerPassthroughServiceImplementation<audio::V4_0::IDevicesFactory>() != OK &&
                 registerPassthroughServiceImplementation<audio::V2_0::IDevicesFactory>() != OK;
-    LOG_ALWAYS_FATAL_IF(fail, "Could not register audio core API 2.0 nor 4.0");
+    LOG_ALWAYS_FATAL_IF(fail, "Could not register audio core API 2, 4 nor 5");
 
-    fail = registerPassthroughServiceImplementation<audio::effect::V4_0::IEffectsFactory>() != OK &&
+    fail = registerPassthroughServiceImplementation<audio::effect::V5_0::IEffectsFactory>() != OK &&
+           registerPassthroughServiceImplementation<audio::effect::V4_0::IEffectsFactory>() != OK &&
            registerPassthroughServiceImplementation<audio::effect::V2_0::IEffectsFactory>() != OK,
-    LOG_ALWAYS_FATAL_IF(fail, "Could not register audio effect API 2.0 nor 4.0");
+    LOG_ALWAYS_FATAL_IF(fail, "Could not register audio effect API 2, 4 nor 5");
 
     fail = registerPassthroughServiceImplementation<soundtrigger::V2_1::ISoundTriggerHw>() != OK &&
            registerPassthroughServiceImplementation<soundtrigger::V2_0::ISoundTriggerHw>() != OK,
diff --git a/audio/common/all-versions/test/utility/include/utility/AssertOk.h b/audio/common/all-versions/test/utility/include/utility/AssertOk.h
index 11e1c24..5ac2fdc 100644
--- a/audio/common/all-versions/test/utility/include/utility/AssertOk.h
+++ b/audio/common/all-versions/test/utility/include/utility/AssertOk.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/test/utility/include/utility/Documentation.h b/audio/common/all-versions/test/utility/include/utility/Documentation.h
index e10cf79..1b555b9 100644
--- a/audio/common/all-versions/test/utility/include/utility/Documentation.h
+++ b/audio/common/all-versions/test/utility/include/utility/Documentation.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h b/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h
index 7a08a54..0e416f3 100644
--- a/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h
+++ b/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/test/utility/include/utility/PrettyPrintAudioTypes.h b/audio/common/all-versions/test/utility/include/utility/PrettyPrintAudioTypes.h
index abc2ff5..3833fd0 100644
--- a/audio/common/all-versions/test/utility/include/utility/PrettyPrintAudioTypes.h
+++ b/audio/common/all-versions/test/utility/include/utility/PrettyPrintAudioTypes.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,10 +14,6 @@
  * limitations under the License.
  */
 
-#ifndef AUDIO_HAL_VERSION
-#error "AUDIO_HAL_VERSION must be set before including this file."
-#endif
-
 #ifndef ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_PRETTY_PRINT_AUDIO_TYPES_H
 #define ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_PRETTY_PRINT_AUDIO_TYPES_H
 
@@ -40,19 +36,19 @@
 #define DEFINE_GTEST_PRINT_TO(T) \
     inline void PrintTo(const T& val, ::std::ostream* os) { *os << toString(val); }
 
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 DEFINE_GTEST_PRINT_TO(IPrimaryDevice::TtyMode)
 DEFINE_GTEST_PRINT_TO(Result)
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 
 namespace common {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 DEFINE_GTEST_PRINT_TO(AudioConfig)
 DEFINE_GTEST_PRINT_TO(AudioMode)
 DEFINE_GTEST_PRINT_TO(AudioDevice)
 DEFINE_GTEST_PRINT_TO(AudioFormat)
 DEFINE_GTEST_PRINT_TO(AudioChannelMask)
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace common
 
 #undef DEFINE_GTEST_PRINT_TO
diff --git a/audio/common/all-versions/test/utility/include/utility/ReturnIn.h b/audio/common/all-versions/test/utility/include/utility/ReturnIn.h
index 7fd0d4a..de16809 100644
--- a/audio/common/all-versions/test/utility/include/utility/ReturnIn.h
+++ b/audio/common/all-versions/test/utility/include/utility/ReturnIn.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/test/utility/include/utility/ValidateXml.h b/audio/common/all-versions/test/utility/include/utility/ValidateXml.h
index 91adfc1..ee206f7 100644
--- a/audio/common/all-versions/test/utility/include/utility/ValidateXml.h
+++ b/audio/common/all-versions/test/utility/include/utility/ValidateXml.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/test/utility/src/ValidateXml.cpp b/audio/common/all-versions/test/utility/src/ValidateXml.cpp
index 1a906d6..bdafa82 100644
--- a/audio/common/all-versions/test/utility/src/ValidateXml.cpp
+++ b/audio/common/all-versions/test/utility/src/ValidateXml.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -162,8 +162,8 @@
            << "\n                 Which is: " << xmlFileName
            << "\n In the following folders: " << xmlFileLocationsExpr
            << "\n                 Which is: " << ::testing::PrintToString(xmlFileLocations)
-           << (atLeastOneRequired ? "Where at least one file must be found."
-                                  : "Where no file might exist.");
+           << (atLeastOneRequired ? "\nWhere at least one file must be found."
+                                  : "\nWhere no file might exist.");
 }
 
 template ::testing::AssertionResult validateXmlMultipleLocations<true>(const char*, const char*,
diff --git a/audio/common/all-versions/util/Android.bp b/audio/common/all-versions/util/Android.bp
index 5d33a3a..3c7e62e 100644
--- a/audio/common/all-versions/util/Android.bp
+++ b/audio/common/all-versions/util/Android.bp
@@ -2,9 +2,6 @@
     name: "android.hardware.audio.common.util@all-versions",
     defaults: ["hidl_defaults"],
     vendor_available: true,
-    vndk: {
-        enabled: true,
-    },
 
     export_include_dirs: ["include"],
 }
diff --git a/audio/common/all-versions/util/include/common/all-versions/IncludeGuard.h b/audio/common/all-versions/util/include/common/all-versions/IncludeGuard.h
deleted file mode 100644
index 2d54816..0000000
--- a/audio/common/all-versions/util/include/common/all-versions/IncludeGuard.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef AUDIO_HAL_VERSION
-#error "AUDIO_HAL_VERSION must be set before including this file."
-#endif
diff --git a/audio/common/all-versions/util/include/common/all-versions/VersionMacro.h b/audio/common/all-versions/util/include/common/all-versions/VersionMacro.h
new file mode 100644
index 0000000..dc54cee
--- /dev/null
+++ b/audio/common/all-versions/util/include/common/all-versions/VersionMacro.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HARDWARE_VERSION_MACRO_H
+#define ANDROID_HARDWARE_VERSION_MACRO_H
+
+#if !defined(MAJOR_VERSION) || !defined(MINOR_VERSION)
+#error "MAJOR_VERSION and MINOR_VERSION must be defined"
+#endif
+
+/** Allows macro expansion for x and add surrounding `<>`.
+ * Is intended to be used for version dependant includes as
+ * `#include` do not macro expand if starting with < or "
+ * Example usage:
+ *      #include PATH(path/to/FILE_VERSION/file)
+ * @note: uses the implementation-define "Computed Includes" feature.
+ */
+#define PATH(x) <x>
+
+#define CONCAT_3(a, b, c) a##b##c
+#define EXPAND_CONCAT_3(a, b, c) CONCAT_3(a, b, c)
+/** The directory name of the version: <major>.<minor> */
+#define FILE_VERSION EXPAND_CONCAT_3(MAJOR_VERSION, ., MINOR_VERSION)
+
+#define CONCAT_4(a, b, c, d) a##b##c##d
+#define EXPAND_CONCAT_4(a, b, c, d) CONCAT_4(a, b, c, d)
+/** The c++ namespace of the version: V<major>_<minor> */
+#define CPP_VERSION EXPAND_CONCAT_4(V, MAJOR_VERSION, _, MINOR_VERSION)
+
+#endif  // ANDROID_HARDWARE_VERSION_MACRO_H
diff --git a/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h b/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h
index 70c3d56..3b5c0fb 100644
--- a/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h
+++ b/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h
@@ -26,36 +26,31 @@
 namespace common {
 namespace utils {
 
-/** Similar to static_cast but also casts to hidl_bitfield depending on
- * return type inference (emulated through user-define conversion).
- */
-template <class Source, class Destination = Source>
-class EnumConverter {
+/** Converting between a bitfield or itself. */
+template <class Enum>
+class EnumBitfield {
    public:
-    static_assert(std::is_enum<Source>::value || std::is_enum<Destination>::value,
-                  "Source or destination should be an enum");
+    using Bitfield = ::android::hardware::hidl_bitfield<Enum>;
 
-    explicit EnumConverter(Source source) : mSource(source) {}
+    EnumBitfield(const EnumBitfield&) = default;
+    explicit EnumBitfield(Enum value) : mValue(value) {}
+    explicit EnumBitfield(Bitfield value) : EnumBitfield(static_cast<Enum>(value)) {}
 
-    operator Destination() const { return static_cast<Destination>(mSource); }
+    EnumBitfield& operator=(const EnumBitfield&) = default;
+    EnumBitfield& operator=(Enum value) { return *this = EnumBitfield{value}; }
+    EnumBitfield& operator=(Bitfield value) { return *this = EnumBitfield{value}; }
 
-    template <class = std::enable_if_t<std::is_enum<Destination>::value>>
-    operator ::android::hardware::hidl_bitfield<Destination>() {
-        return static_cast<std::underlying_type_t<Destination>>(mSource);
-    }
+    operator Enum() const { return mValue; }
+    operator Bitfield() const { return static_cast<Bitfield>(mValue); }
 
    private:
-    const Source mSource;
+    Enum mValue;
 };
-template <class Destination, class Source>
-auto mkEnumConverter(Source source) {
-    return EnumConverter<Source, Destination>{source};
-}
 
-/** Allows converting an enum to its bitfield or itself. */
+/** ATD way to create a EnumBitfield. */
 template <class Enum>
-EnumConverter<Enum> mkBitfield(Enum value) {
-    return EnumConverter<Enum>{value};
+EnumBitfield<Enum> mkEnumBitfield(Enum value) {
+    return EnumBitfield<Enum>{value};
 }
 
 }  // namespace utils
diff --git a/audio/core/2.0/default/Android.bp b/audio/core/2.0/default/Android.bp
deleted file mode 100644
index 625df74..0000000
--- a/audio/core/2.0/default/Android.bp
+++ /dev/null
@@ -1,53 +0,0 @@
-cc_library_shared {
-    name: "android.hardware.audio@2.0-impl",
-    relative_install_path: "hw",
-    proprietary: true,
-    vendor: true,
-    srcs: [
-        "Conversions.cpp",
-        "Device.cpp",
-        "DevicesFactory.cpp",
-        "ParametersUtil.cpp",
-        "PrimaryDevice.cpp",
-        "Stream.cpp",
-        "StreamIn.cpp",
-        "StreamOut.cpp",
-    ],
-
-    cflags: [
-        "-DAUDIO_HAL_VERSION_2_0",
-    ],
-
-    defaults: ["hidl_defaults"],
-
-    export_include_dirs: ["include"],
-
-    shared_libs: [
-        "libbase",
-        "libcutils",
-        "libfmq",
-        "libhardware",
-        "libhidlbase",
-        "libhidltransport",
-        "liblog",
-        "libutils",
-        "android.hardware.audio@2.0",
-        "android.hardware.audio.common@2.0",
-        "android.hardware.audio.common@2.0-util",
-        "android.hardware.audio.common-util",
-    ],
-
-    header_libs: [
-        "android.hardware.audio.common.util@all-versions",
-        "android.hardware.audio.core@all-versions-impl",
-        "libaudioclient_headers",
-        "libaudio_system_headers",
-        "libhardware_headers",
-        "libmedia_headers",
-    ],
-
-    whole_static_libs: [
-        "libmedia_helper",
-    ],
-
-}
diff --git a/audio/core/2.0/default/Conversions.cpp b/audio/core/2.0/default/Conversions.cpp
deleted file mode 100644
index 6c32090..0000000
--- a/audio/core/2.0/default/Conversions.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "core/2.0/default/Conversions.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/Conversions.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/2.0/default/Device.cpp b/audio/core/2.0/default/Device.cpp
deleted file mode 100644
index b67203d..0000000
--- a/audio/core/2.0/default/Device.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "DeviceHAL"
-
-#include "core/2.0/default/Device.h"
-#include <HidlUtils.h>
-#include "core/2.0/default/Conversions.h"
-#include "core/2.0/default/StreamIn.h"
-#include "core/2.0/default/StreamOut.h"
-#include "core/2.0/default/Util.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/Device.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/2.0/default/DevicesFactory.cpp b/audio/core/2.0/default/DevicesFactory.cpp
deleted file mode 100644
index 65a9ccd..0000000
--- a/audio/core/2.0/default/DevicesFactory.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "DevicesFactoryHAL"
-
-#include "core/2.0/default/DevicesFactory.h"
-#include "core/2.0/default/Device.h"
-#include "core/2.0/default/PrimaryDevice.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/DevicesFactory.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/2.0/default/OWNERS b/audio/core/2.0/default/OWNERS
deleted file mode 100644
index 6fdc97c..0000000
--- a/audio/core/2.0/default/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-elaurent@google.com
-krocard@google.com
-mnaganov@google.com
diff --git a/audio/core/2.0/default/ParametersUtil.cpp b/audio/core/2.0/default/ParametersUtil.cpp
deleted file mode 100644
index 963e291..0000000
--- a/audio/core/2.0/default/ParametersUtil.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "core/2.0/default/ParametersUtil.h"
-#include "core/2.0/default/Util.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/ParametersUtil.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/2.0/default/PrimaryDevice.cpp b/audio/core/2.0/default/PrimaryDevice.cpp
deleted file mode 100644
index decaa14..0000000
--- a/audio/core/2.0/default/PrimaryDevice.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "PrimaryDeviceHAL"
-
-#include "core/2.0/default/PrimaryDevice.h"
-#include "core/2.0/default/Util.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/PrimaryDevice.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/2.0/default/Stream.cpp b/audio/core/2.0/default/Stream.cpp
deleted file mode 100644
index 0863a7c..0000000
--- a/audio/core/2.0/default/Stream.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "StreamHAL"
-
-#include "core/2.0/default/Stream.h"
-#include "common/all-versions/default/EffectMap.h"
-#include "core/2.0/default/Conversions.h"
-#include "core/2.0/default/Util.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/Stream.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/2.0/default/StreamIn.cpp b/audio/core/2.0/default/StreamIn.cpp
deleted file mode 100644
index 2021df1..0000000
--- a/audio/core/2.0/default/StreamIn.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "StreamInHAL"
-
-#include "core/2.0/default/StreamIn.h"
-#include "core/2.0/default/Util.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/StreamIn.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/2.0/default/StreamOut.cpp b/audio/core/2.0/default/StreamOut.cpp
deleted file mode 100644
index 940a251..0000000
--- a/audio/core/2.0/default/StreamOut.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "StreamOutHAL"
-
-#include "core/2.0/default/StreamOut.h"
-#include "core/2.0/default/Util.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/StreamOut.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/2.0/default/include/core/2.0/default/Conversions.h b/audio/core/2.0/default/include/core/2.0/default/Conversions.h
deleted file mode 100644
index b3a6ea8..0000000
--- a/audio/core/2.0/default/include/core/2.0/default/Conversions.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V2_0_CONVERSIONS_H_
-#define ANDROID_HARDWARE_AUDIO_V2_0_CONVERSIONS_H_
-
-#include <android/hardware/audio/2.0/types.h>
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/Conversions.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V2_0_CONVERSIONS_H_
diff --git a/audio/core/2.0/default/include/core/2.0/default/Device.h b/audio/core/2.0/default/include/core/2.0/default/Device.h
deleted file mode 100644
index 3ec7464..0000000
--- a/audio/core/2.0/default/include/core/2.0/default/Device.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H
-#define ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H
-
-#include <android/hardware/audio/2.0/IDevice.h>
-
-#include "ParametersUtil.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/Device.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H
diff --git a/audio/core/2.0/default/include/core/2.0/default/DevicesFactory.h b/audio/core/2.0/default/include/core/2.0/default/DevicesFactory.h
deleted file mode 100644
index 8e8ee88..0000000
--- a/audio/core/2.0/default/include/core/2.0/default/DevicesFactory.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V2_0_DEVICESFACTORY_H
-#define ANDROID_HARDWARE_AUDIO_V2_0_DEVICESFACTORY_H
-
-#include <android/hardware/audio/2.0/IDevicesFactory.h>
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/DevicesFactory.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V2_0_DEVICESFACTORY_H
diff --git a/audio/core/2.0/default/include/core/2.0/default/ParametersUtil.h b/audio/core/2.0/default/include/core/2.0/default/ParametersUtil.h
deleted file mode 100644
index a5c1c78..0000000
--- a/audio/core/2.0/default/include/core/2.0/default/ParametersUtil.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V2_0_PARAMETERS_UTIL_H_
-#define ANDROID_HARDWARE_AUDIO_V2_0_PARAMETERS_UTIL_H_
-
-#include <android/hardware/audio/2.0/types.h>
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/ParametersUtil.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V2_0_PARAMETERS_UTIL_H_
diff --git a/audio/core/2.0/default/include/core/2.0/default/PrimaryDevice.h b/audio/core/2.0/default/include/core/2.0/default/PrimaryDevice.h
deleted file mode 100644
index f898597..0000000
--- a/audio/core/2.0/default/include/core/2.0/default/PrimaryDevice.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V2_0_PRIMARYDEVICE_H
-#define ANDROID_HARDWARE_AUDIO_V2_0_PRIMARYDEVICE_H
-
-#include <android/hardware/audio/2.0/IPrimaryDevice.h>
-
-#include "Device.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/PrimaryDevice.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V2_0_PRIMARYDEVICE_H
diff --git a/audio/core/2.0/default/include/core/2.0/default/Stream.h b/audio/core/2.0/default/include/core/2.0/default/Stream.h
deleted file mode 100644
index a2d8456..0000000
--- a/audio/core/2.0/default/include/core/2.0/default/Stream.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H
-#define ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H
-
-#include <android/hardware/audio/2.0/IStream.h>
-
-#include "ParametersUtil.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/Stream.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H
diff --git a/audio/core/2.0/default/include/core/2.0/default/StreamIn.h b/audio/core/2.0/default/include/core/2.0/default/StreamIn.h
deleted file mode 100644
index c36abbd..0000000
--- a/audio/core/2.0/default/include/core/2.0/default/StreamIn.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V2_0_STREAMIN_H
-#define ANDROID_HARDWARE_AUDIO_V2_0_STREAMIN_H
-
-#include <android/hardware/audio/2.0/IStreamIn.h>
-
-#include "Device.h"
-#include "Stream.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/StreamIn.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V2_0_STREAMIN_H
diff --git a/audio/core/2.0/default/include/core/2.0/default/StreamOut.h b/audio/core/2.0/default/include/core/2.0/default/StreamOut.h
deleted file mode 100644
index ab35687..0000000
--- a/audio/core/2.0/default/include/core/2.0/default/StreamOut.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V2_0_STREAMOUT_H
-#define ANDROID_HARDWARE_AUDIO_V2_0_STREAMOUT_H
-
-#include <android/hardware/audio/2.0/IStreamOut.h>
-
-#include "Device.h"
-#include "Stream.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/StreamOut.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V2_0_STREAMOUT_H
diff --git a/audio/core/2.0/default/include/core/2.0/default/Util.h b/audio/core/2.0/default/include/core/2.0/default/Util.h
deleted file mode 100644
index 1f0e284..0000000
--- a/audio/core/2.0/default/include/core/2.0/default/Util.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V2_0_UTIL_H
-#define ANDROID_HARDWARE_AUDIO_V2_0_UTIL_H
-
-#include <android/hardware/audio/2.0/types.h>
-
-#define AUDIO_HAL_VERSION V2_0
-#include <core/all-versions/default/Util.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V2_0_UTIL_H
diff --git a/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
deleted file mode 100644
index a08a2d6..0000000
--- a/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ /dev/null
@@ -1,1280 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "VtsHalAudioV2_0TargetTest"
-
-#include <algorithm>
-#include <cmath>
-#include <cstddef>
-#include <cstdio>
-#include <initializer_list>
-#include <limits>
-#include <string>
-#include <vector>
-
-#include <fcntl.h>
-#include <unistd.h>
-
-#include <VtsHalHidlTargetTestBase.h>
-
-#include <android-base/logging.h>
-
-#include <android/hardware/audio/2.0/IDevice.h>
-#include <android/hardware/audio/2.0/IDevicesFactory.h>
-#include <android/hardware/audio/2.0/IPrimaryDevice.h>
-#include <android/hardware/audio/2.0/types.h>
-#include <android/hardware/audio/common/2.0/types.h>
-
-#include "utility/AssertOk.h"
-#include "utility/Documentation.h"
-#include "utility/EnvironmentTearDown.h"
-#define AUDIO_HAL_VERSION V2_0
-#include "utility/PrettyPrintAudioTypes.h"
-#include "utility/ReturnIn.h"
-
-using std::initializer_list;
-using std::string;
-using std::to_string;
-using std::vector;
-
-using ::android::sp;
-using ::android::hardware::Return;
-using ::android::hardware::hidl_handle;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::MQDescriptorSync;
-using ::android::hardware::audio::V2_0::AudioDrain;
-using ::android::hardware::audio::V2_0::DeviceAddress;
-using ::android::hardware::audio::V2_0::IDevice;
-using ::android::hardware::audio::V2_0::IPrimaryDevice;
-using TtyMode = ::android::hardware::audio::V2_0::IPrimaryDevice::TtyMode;
-using ::android::hardware::audio::V2_0::IDevicesFactory;
-using ::android::hardware::audio::V2_0::IStream;
-using ::android::hardware::audio::V2_0::IStreamIn;
-using ::android::hardware::audio::V2_0::TimeSpec;
-using ReadParameters = ::android::hardware::audio::V2_0::IStreamIn::ReadParameters;
-using ReadStatus = ::android::hardware::audio::V2_0::IStreamIn::ReadStatus;
-using ::android::hardware::audio::V2_0::IStreamOut;
-using ::android::hardware::audio::V2_0::IStreamOutCallback;
-using ::android::hardware::audio::V2_0::MmapBufferInfo;
-using ::android::hardware::audio::V2_0::MmapPosition;
-using ::android::hardware::audio::V2_0::ParameterValue;
-using ::android::hardware::audio::V2_0::Result;
-using ::android::hardware::audio::common::V2_0::AudioChannelMask;
-using ::android::hardware::audio::common::V2_0::AudioConfig;
-using ::android::hardware::audio::common::V2_0::AudioDevice;
-using ::android::hardware::audio::common::V2_0::AudioFormat;
-using ::android::hardware::audio::common::V2_0::AudioHandleConsts;
-using ::android::hardware::audio::common::V2_0::AudioInputFlag;
-using ::android::hardware::audio::common::V2_0::AudioIoHandle;
-using ::android::hardware::audio::common::V2_0::AudioMode;
-using ::android::hardware::audio::common::V2_0::AudioOffloadInfo;
-using ::android::hardware::audio::common::V2_0::AudioOutputFlag;
-using ::android::hardware::audio::common::V2_0::AudioSource;
-using ::android::hardware::audio::common::V2_0::ThreadInfo;
-
-using namespace ::android::hardware::audio::common::test::utility;
-
-class AudioHidlTestEnvironment : public ::Environment {
-   public:
-    virtual void registerTestServices() override { registerTestService<IDevicesFactory>(); }
-};
-
-// Instance to register global tearDown
-static AudioHidlTestEnvironment* environment;
-
-class HidlTest : public ::testing::VtsHalHidlTargetTestBase {
-   protected:
-    // Convenient member to store results
-    Result res;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-////////////////////// getService audio_devices_factory //////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-// Test all audio devices
-class AudioHidlTest : public HidlTest {
-   public:
-    void SetUp() override {
-        ASSERT_NO_FATAL_FAILURE(HidlTest::SetUp());  // setup base
-
-        if (devicesFactory == nullptr) {
-            environment->registerTearDown([] { devicesFactory.clear(); });
-            devicesFactory = ::testing::VtsHalHidlTargetTestBase::getService<IDevicesFactory>(
-                environment->getServiceName<IDevicesFactory>("default"));
-        }
-        ASSERT_TRUE(devicesFactory != nullptr);
-    }
-
-   protected:
-    // Cache the devicesFactory retrieval to speed up each test by ~0.5s
-    static sp<IDevicesFactory> devicesFactory;
-};
-sp<IDevicesFactory> AudioHidlTest::devicesFactory;
-
-TEST_F(AudioHidlTest, GetAudioDevicesFactoryService) {
-    doc::test("test the getService (called in SetUp)");
-}
-
-TEST_F(AudioHidlTest, OpenDeviceInvalidParameter) {
-    doc::test("test passing an invalid parameter to openDevice");
-    IDevicesFactory::Result result;
-    sp<IDevice> device;
-    ASSERT_OK(devicesFactory->openDevice(IDevicesFactory::Device(-1), returnIn(result, device)));
-    ASSERT_EQ(IDevicesFactory::Result::INVALID_ARGUMENTS, result);
-    ASSERT_TRUE(device == nullptr);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-/////////////////////////////// openDevice primary ///////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-// Test the primary device
-class AudioPrimaryHidlTest : public AudioHidlTest {
-   public:
-    /** Primary HAL test are NOT thread safe. */
-    void SetUp() override {
-        ASSERT_NO_FATAL_FAILURE(AudioHidlTest::SetUp());  // setup base
-
-        if (device == nullptr) {
-            IDevicesFactory::Result result;
-            sp<IDevice> baseDevice;
-            ASSERT_OK(devicesFactory->openDevice(IDevicesFactory::Device::PRIMARY,
-                                                 returnIn(result, baseDevice)));
-            ASSERT_OK(result);
-            ASSERT_TRUE(baseDevice != nullptr);
-
-            environment->registerTearDown([] { device.clear(); });
-            device = IPrimaryDevice::castFrom(baseDevice);
-            ASSERT_TRUE(device != nullptr);
-        }
-    }
-
-   protected:
-    // Cache the device opening to speed up each test by ~0.5s
-    static sp<IPrimaryDevice> device;
-};
-sp<IPrimaryDevice> AudioPrimaryHidlTest::device;
-
-TEST_F(AudioPrimaryHidlTest, OpenPrimaryDevice) {
-    doc::test("Test the openDevice (called in SetUp)");
-}
-
-TEST_F(AudioPrimaryHidlTest, Init) {
-    doc::test("Test that the audio primary hal initialized correctly");
-    ASSERT_OK(device->initCheck());
-}
-
-//////////////////////////////////////////////////////////////////////////////
-///////////////////// {set,get}{Master,Mic}{Mute,Volume} /////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-template <class Property>
-class AccessorPrimaryHidlTest : public AudioPrimaryHidlTest {
-   protected:
-    /** Test a property getter and setter. */
-    template <class Getter, class Setter>
-    void testAccessors(const string& propertyName, const vector<Property>& valuesToTest,
-                       Setter setter, Getter getter, const vector<Property>& invalidValues = {}) {
-        Property initialValue;  // Save initial value to restore it at the end
-                                // of the test
-        ASSERT_OK((device.get()->*getter)(returnIn(res, initialValue)));
-        ASSERT_OK(res);
-
-        for (Property setValue : valuesToTest) {
-            SCOPED_TRACE("Test " + propertyName + " getter and setter for " +
-                         testing::PrintToString(setValue));
-            ASSERT_OK((device.get()->*setter)(setValue));
-            Property getValue;
-            // Make sure the getter returns the same value just set
-            ASSERT_OK((device.get()->*getter)(returnIn(res, getValue)));
-            ASSERT_OK(res);
-            EXPECT_EQ(setValue, getValue);
-        }
-
-        for (Property invalidValue : invalidValues) {
-            SCOPED_TRACE("Try to set " + propertyName + " with the invalid value " +
-                         testing::PrintToString(invalidValue));
-            EXPECT_RESULT(Result::INVALID_ARGUMENTS, (device.get()->*setter)(invalidValue));
-        }
-
-        ASSERT_OK((device.get()->*setter)(initialValue));  // restore initial value
-    }
-
-    /** Test the getter and setter of an optional feature. */
-    template <class Getter, class Setter>
-    void testOptionalAccessors(const string& propertyName, const vector<Property>& valuesToTest,
-                               Setter setter, Getter getter,
-                               const vector<Property>& invalidValues = {}) {
-        doc::test("Test the optional " + propertyName + " getters and setter");
-        {
-            SCOPED_TRACE("Test feature support by calling the getter");
-            Property initialValue;
-            ASSERT_OK((device.get()->*getter)(returnIn(res, initialValue)));
-            if (res == Result::NOT_SUPPORTED) {
-                doc::partialTest(propertyName + " getter is not supported");
-                return;
-            }
-            ASSERT_OK(res);  // If it is supported it must succeed
-        }
-        // The feature is supported, test it
-        testAccessors(propertyName, valuesToTest, setter, getter, invalidValues);
-    }
-};
-
-using BoolAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<bool>;
-
-TEST_F(BoolAccessorPrimaryHidlTest, MicMuteTest) {
-    doc::test("Check that the mic can be muted and unmuted");
-    testAccessors("mic mute", {true, false, true}, &IDevice::setMicMute, &IDevice::getMicMute);
-    // TODO: check that the mic is really muted (all sample are 0)
-}
-
-TEST_F(BoolAccessorPrimaryHidlTest, MasterMuteTest) {
-    doc::test(
-        "If master mute is supported, try to mute and unmute the master "
-        "output");
-    testOptionalAccessors("master mute", {true, false, true}, &IDevice::setMasterMute,
-                          &IDevice::getMasterMute);
-    // TODO: check that the master volume is really muted
-}
-
-using FloatAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<float>;
-TEST_F(FloatAccessorPrimaryHidlTest, MasterVolumeTest) {
-    doc::test("Test the master volume if supported");
-    testOptionalAccessors(
-        "master volume", {0, 0.5, 1}, &IDevice::setMasterVolume, &IDevice::getMasterVolume,
-        {-0.1, 1.1, NAN, INFINITY, -INFINITY, 1 + std::numeric_limits<float>::epsilon()});
-    // TODO: check that the master volume is really changed
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////// AudioPatches ////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-class AudioPatchPrimaryHidlTest : public AudioPrimaryHidlTest {
-   protected:
-    bool areAudioPatchesSupported() {
-        auto result = device->supportsAudioPatches();
-        EXPECT_IS_OK(result);
-        return result;
-    }
-};
-
-TEST_F(AudioPatchPrimaryHidlTest, AudioPatches) {
-    doc::test("Test if audio patches are supported");
-    if (!areAudioPatchesSupported()) {
-        doc::partialTest("Audio patches are not supported");
-        return;
-    }
-    // TODO: test audio patches
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////// Required and recommended audio format support ///////////////
-// From:
-// https://source.android.com/compatibility/android-cdd.html#5_4_audio_recording
-// From:
-// https://source.android.com/compatibility/android-cdd.html#5_5_audio_playback
-/////////// TODO: move to the beginning of the file for easier update ////////
-//////////////////////////////////////////////////////////////////////////////
-
-class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest {
-   public:
-    // Cache result ?
-    static const vector<AudioConfig> getRequiredSupportPlaybackAudioConfig() {
-        return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
-                                  {8000, 11025, 16000, 22050, 32000, 44100},
-                                  {AudioFormat::PCM_16_BIT});
-    }
-
-    static const vector<AudioConfig> getRecommendedSupportPlaybackAudioConfig() {
-        return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
-                                  {24000, 48000}, {AudioFormat::PCM_16_BIT});
-    }
-
-    static const vector<AudioConfig> getSupportedPlaybackAudioConfig() {
-        // TODO: retrieve audio config supported by the platform
-        // as declared in the policy configuration
-        return {};
-    }
-
-    static const vector<AudioConfig> getRequiredSupportCaptureAudioConfig() {
-        return combineAudioConfig({AudioChannelMask::IN_MONO}, {8000, 11025, 16000, 44100},
-                                  {AudioFormat::PCM_16_BIT});
-    }
-    static const vector<AudioConfig> getRecommendedSupportCaptureAudioConfig() {
-        return combineAudioConfig({AudioChannelMask::IN_STEREO}, {22050, 48000},
-                                  {AudioFormat::PCM_16_BIT});
-    }
-    static const vector<AudioConfig> getSupportedCaptureAudioConfig() {
-        // TODO: retrieve audio config supported by the platform
-        // as declared in the policy configuration
-        return {};
-    }
-
-   private:
-    static const vector<AudioConfig> combineAudioConfig(vector<AudioChannelMask> channelMasks,
-                                                        vector<uint32_t> sampleRates,
-                                                        vector<AudioFormat> formats) {
-        vector<AudioConfig> configs;
-        for (auto channelMask : channelMasks) {
-            for (auto sampleRate : sampleRates) {
-                for (auto format : formats) {
-                    AudioConfig config{};
-                    // leave offloadInfo to 0
-                    config.channelMask = channelMask;
-                    config.sampleRateHz = sampleRate;
-                    config.format = format;
-                    // FIXME: leave frameCount to 0 ?
-                    configs.push_back(config);
-                }
-            }
-        }
-        return configs;
-    }
-};
-
-/** Generate a test name based on an audio config.
- *
- * As the only parameter changing are channel mask and sample rate,
- * only print those ones in the test name.
- */
-static string generateTestName(const testing::TestParamInfo<AudioConfig>& info) {
-    const AudioConfig& config = info.param;
-    return to_string(info.index) + "__" + to_string(config.sampleRateHz) + "_" +
-           // "MONO" is more clear than "FRONT_LEFT"
-           ((config.channelMask == AudioChannelMask::OUT_MONO ||
-             config.channelMask == AudioChannelMask::IN_MONO)
-                ? "MONO"
-                : toString(config.channelMask));
-}
-
-//////////////////////////////////////////////////////////////////////////////
-///////////////////////////// getInputBufferSize /////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-// FIXME: execute input test only if platform declares
-// android.hardware.microphone
-//        how to get this value ? is it a property ???
-
-class AudioCaptureConfigPrimaryTest : public AudioConfigPrimaryTest,
-                                      public ::testing::WithParamInterface<AudioConfig> {
-   protected:
-    void inputBufferSizeTest(const AudioConfig& audioConfig, bool supportRequired) {
-        uint64_t bufferSize;
-        ASSERT_OK(device->getInputBufferSize(audioConfig, returnIn(res, bufferSize)));
-
-        switch (res) {
-            case Result::INVALID_ARGUMENTS:
-                EXPECT_FALSE(supportRequired);
-                break;
-            case Result::OK:
-                // Check that the buffer is of a sane size
-                // For now only that it is > 0
-                EXPECT_GT(bufferSize, uint64_t(0));
-                break;
-            default:
-                FAIL() << "Invalid return status: " << ::testing::PrintToString(res);
-        }
-    }
-};
-
-// Test that the required capture config and those declared in the policy are
-// indeed supported
-class RequiredInputBufferSizeTest : public AudioCaptureConfigPrimaryTest {};
-TEST_P(RequiredInputBufferSizeTest, RequiredInputBufferSizeTest) {
-    doc::test(
-        "Input buffer size must be retrievable for a format with required "
-        "support.");
-    inputBufferSizeTest(GetParam(), true);
-}
-INSTANTIATE_TEST_CASE_P(
-    RequiredInputBufferSize, RequiredInputBufferSizeTest,
-    ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()),
-    &generateTestName);
-INSTANTIATE_TEST_CASE_P(
-    SupportedInputBufferSize, RequiredInputBufferSizeTest,
-    ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()),
-    &generateTestName);
-
-// Test that the recommended capture config are supported or lead to a
-// INVALID_ARGUMENTS return
-class OptionalInputBufferSizeTest : public AudioCaptureConfigPrimaryTest {};
-TEST_P(OptionalInputBufferSizeTest, OptionalInputBufferSizeTest) {
-    doc::test(
-        "Input buffer size should be retrievable for a format with recommended "
-        "support.");
-    inputBufferSizeTest(GetParam(), false);
-}
-INSTANTIATE_TEST_CASE_P(
-    RecommendedCaptureAudioConfigSupport, OptionalInputBufferSizeTest,
-    ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()),
-    &generateTestName);
-
-//////////////////////////////////////////////////////////////////////////////
-/////////////////////////////// setScreenState ///////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-TEST_F(AudioPrimaryHidlTest, setScreenState) {
-    doc::test("Check that the hal can receive the screen state");
-    for (bool turnedOn : {false, true, true, false, false}) {
-        auto ret = device->setScreenState(turnedOn);
-        ASSERT_IS_OK(ret);
-        Result result = ret;
-        auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED};
-        ASSERT_RESULT(okOrNotSupported, result);
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////// {get,set}Parameters /////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-TEST_F(AudioPrimaryHidlTest, getParameters) {
-    doc::test("Check that the hal can set and get parameters");
-    hidl_vec<hidl_string> keys;
-    hidl_vec<ParameterValue> values;
-    ASSERT_OK(device->getParameters(keys, returnIn(res, values)));
-    ASSERT_OK(device->setParameters(values));
-    values.resize(0);
-    ASSERT_OK(device->setParameters(values));
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////// debugDebug //////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-template <class DebugDump>
-static void testDebugDump(DebugDump debugDump) {
-    // File descriptors to our pipe. fds[0] corresponds to the read end and
-    // fds[1] to the write end.
-    int fds[2];
-    ASSERT_EQ(0, pipe2(fds, O_NONBLOCK)) << errno;
-
-    // Make sure that the pipe is at least 1 MB in size. The test process runs
-    // in su domain, so it should be safe to make this call.
-    fcntl(fds[0], F_SETPIPE_SZ, 1 << 20);
-
-    // Wrap the temporary file file descriptor in a native handle
-    auto* nativeHandle = native_handle_create(1, 0);
-    ASSERT_NE(nullptr, nativeHandle);
-    nativeHandle->data[0] = fds[1];
-
-    // Wrap this native handle in a hidl handle
-    hidl_handle handle;
-    handle.setTo(nativeHandle, false /*take ownership*/);
-
-    ASSERT_OK(debugDump(handle));
-
-    // Check that at least one bit was written by the hal
-    // TODO: debugDump does not return a Result.
-    // This mean that the hal can not report that it not implementing the
-    // function.
-    char buff;
-    if (read(fds[0], &buff, 1) != 1) {
-        doc::note("debugDump does not seem implemented");
-    }
-    EXPECT_EQ(0, close(fds[0])) << errno;
-    EXPECT_EQ(0, close(fds[1])) << errno;
-}
-
-TEST_F(AudioPrimaryHidlTest, DebugDump) {
-    doc::test("Check that the hal can dump its state without error");
-    testDebugDump([](const auto& handle) { return device->debugDump(handle); });
-}
-
-TEST_F(AudioPrimaryHidlTest, DebugDumpInvalidArguments) {
-    doc::test("Check that the hal dump doesn't crash on invalid arguments");
-    ASSERT_OK(device->debugDump(hidl_handle()));
-}
-
-//////////////////////////////////////////////////////////////////////////////
-////////////////////////// open{Output,Input}Stream //////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-template <class Stream>
-class OpenStreamTest : public AudioConfigPrimaryTest,
-                       public ::testing::WithParamInterface<AudioConfig> {
-   protected:
-    template <class Open>
-    void testOpen(Open openStream, const AudioConfig& config) {
-        // FIXME: Open a stream without an IOHandle
-        //        This is not required to be accepted by hal implementations
-        AudioIoHandle ioHandle = (AudioIoHandle)AudioHandleConsts::AUDIO_IO_HANDLE_NONE;
-        AudioConfig suggestedConfig{};
-        ASSERT_OK(openStream(ioHandle, config, returnIn(res, stream, suggestedConfig)));
-
-        // TODO: only allow failure for RecommendedPlaybackAudioConfig
-        switch (res) {
-            case Result::OK:
-                ASSERT_TRUE(stream != nullptr);
-                audioConfig = config;
-                break;
-            case Result::INVALID_ARGUMENTS:
-                ASSERT_TRUE(stream == nullptr);
-                AudioConfig suggestedConfigRetry;
-                // Could not open stream with config, try again with the
-                // suggested one
-                ASSERT_OK(openStream(ioHandle, suggestedConfig,
-                                     returnIn(res, stream, suggestedConfigRetry)));
-                // This time it must succeed
-                ASSERT_OK(res);
-                ASSERT_TRUE(stream != nullptr);
-                audioConfig = suggestedConfig;
-                break;
-            default:
-                FAIL() << "Invalid return status: " << ::testing::PrintToString(res);
-        }
-        open = true;
-    }
-
-    Return<Result> closeStream() {
-        open = false;
-        return stream->close();
-    }
-
-   private:
-    void TearDown() override {
-        if (open) {
-            ASSERT_OK(stream->close());
-        }
-    }
-
-   protected:
-    AudioConfig audioConfig;
-    DeviceAddress address = {};
-    sp<Stream> stream;
-    bool open = false;
-};
-
-////////////////////////////// openOutputStream //////////////////////////////
-
-class OutputStreamTest : public OpenStreamTest<IStreamOut> {
-    virtual void SetUp() override {
-        ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp());  // setup base
-        address.device = AudioDevice::OUT_DEFAULT;
-        const AudioConfig& config = GetParam();
-        AudioOutputFlag flags = AudioOutputFlag::NONE;  // TODO: test all flag combination
-        testOpen(
-            [&](AudioIoHandle handle, AudioConfig config, auto cb) {
-                return device->openOutputStream(handle, address, config, flags, cb);
-            },
-            config);
-    }
-};
-TEST_P(OutputStreamTest, OpenOutputStreamTest) {
-    doc::test(
-        "Check that output streams can be open with the required and "
-        "recommended config");
-    // Open done in SetUp
-}
-INSTANTIATE_TEST_CASE_P(
-    RequiredOutputStreamConfigSupport, OutputStreamTest,
-    ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportPlaybackAudioConfig()),
-    &generateTestName);
-INSTANTIATE_TEST_CASE_P(
-    SupportedOutputStreamConfig, OutputStreamTest,
-    ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedPlaybackAudioConfig()),
-    &generateTestName);
-
-INSTANTIATE_TEST_CASE_P(
-    RecommendedOutputStreamConfigSupport, OutputStreamTest,
-    ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportPlaybackAudioConfig()),
-    &generateTestName);
-
-////////////////////////////// openInputStream //////////////////////////////
-
-class InputStreamTest : public OpenStreamTest<IStreamIn> {
-    virtual void SetUp() override {
-        ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp());  // setup base
-        address.device = AudioDevice::IN_DEFAULT;
-        const AudioConfig& config = GetParam();
-        AudioInputFlag flags = AudioInputFlag::NONE;  // TODO: test all flag combination
-        AudioSource source = AudioSource::DEFAULT;    // TODO: test all flag combination
-        testOpen(
-            [&](AudioIoHandle handle, AudioConfig config, auto cb) {
-                return device->openInputStream(handle, address, config, flags, source, cb);
-            },
-            config);
-    }
-};
-
-TEST_P(InputStreamTest, OpenInputStreamTest) {
-    doc::test(
-        "Check that input streams can be open with the required and "
-        "recommended config");
-    // Open done in setup
-}
-INSTANTIATE_TEST_CASE_P(
-    RequiredInputStreamConfigSupport, InputStreamTest,
-    ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()),
-    &generateTestName);
-INSTANTIATE_TEST_CASE_P(
-    SupportedInputStreamConfig, InputStreamTest,
-    ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()),
-    &generateTestName);
-
-INSTANTIATE_TEST_CASE_P(
-    RecommendedInputStreamConfigSupport, InputStreamTest,
-    ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()),
-    &generateTestName);
-
-//////////////////////////////////////////////////////////////////////////////
-////////////////////////////// IStream getters ///////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-/** Unpack the provided result.
- * If the result is not OK, register a failure and return an undefined value. */
-template <class R>
-static R extract(Return<R> ret) {
-    if (!ret.isOk()) {
-        EXPECT_IS_OK(ret);
-        return R{};
-    }
-    return ret;
-}
-
-/* Could not find a way to write a test for two parametrized class fixure
- * thus use this macro do duplicate tests for Input and Output stream */
-#define TEST_IO_STREAM(test_name, documentation, code) \
-    TEST_P(InputStreamTest, test_name) {               \
-        doc::test(documentation);                      \
-        code;                                          \
-    }                                                  \
-    TEST_P(OutputStreamTest, test_name) {              \
-        doc::test(documentation);                      \
-        code;                                          \
-    }
-
-TEST_IO_STREAM(GetFrameCount, "Check that getting stream frame count does not crash the HAL.",
-               ASSERT_TRUE(stream->getFrameCount().isOk()))
-
-TEST_IO_STREAM(GetSampleRate, "Check that the stream sample rate == the one it was opened with",
-               ASSERT_EQ(audioConfig.sampleRateHz, extract(stream->getSampleRate())))
-
-TEST_IO_STREAM(GetChannelMask, "Check that the stream channel mask == the one it was opened with",
-               ASSERT_EQ(audioConfig.channelMask, extract(stream->getChannelMask())))
-
-TEST_IO_STREAM(GetFormat, "Check that the stream format == the one it was opened with",
-               ASSERT_EQ(audioConfig.format, extract(stream->getFormat())))
-
-// TODO: for now only check that the framesize is not incoherent
-TEST_IO_STREAM(GetFrameSize, "Check that the stream frame size == the one it was opened with",
-               ASSERT_GT(extract(stream->getFrameSize()), 0U))
-
-TEST_IO_STREAM(GetBufferSize, "Check that the stream buffer size== the one it was opened with",
-               ASSERT_GE(extract(stream->getBufferSize()), extract(stream->getFrameSize())));
-
-template <class Property, class CapabilityGetter>
-static void testCapabilityGetter(const string& name, IStream* stream,
-                                 CapabilityGetter capablityGetter,
-                                 Return<Property> (IStream::*getter)(),
-                                 Return<Result> (IStream::*setter)(Property),
-                                 bool currentMustBeSupported = true) {
-    hidl_vec<Property> capabilities;
-    ASSERT_OK((stream->*capablityGetter)(returnIn(capabilities)));
-    if (capabilities.size() == 0) {
-        // The default hal should probably return a NOT_SUPPORTED if the hal
-        // does not expose
-        // capability retrieval. For now it returns an empty list if not
-        // implemented
-        doc::partialTest(name + " is not supported");
-        return;
-    };
-
-    if (currentMustBeSupported) {
-        Property currentValue = extract((stream->*getter)());
-        EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue),
-                  capabilities.end())
-            << "current " << name << " is not in the list of the supported ones "
-            << toString(capabilities);
-    }
-
-    // Check that all declared supported values are indeed supported
-    for (auto capability : capabilities) {
-        auto ret = (stream->*setter)(capability);
-        ASSERT_TRUE(ret.isOk());
-        if (ret == Result::NOT_SUPPORTED) {
-            doc::partialTest("Setter is not supported");
-            return;
-        }
-        ASSERT_OK(ret);
-        ASSERT_EQ(capability, extract((stream->*getter)()));
-    }
-}
-
-TEST_IO_STREAM(SupportedSampleRate, "Check that the stream sample rate is declared as supported",
-               testCapabilityGetter("getSupportedSampleRate", stream.get(),
-                                    &IStream::getSupportedSampleRates, &IStream::getSampleRate,
-                                    &IStream::setSampleRate,
-                                    // getSupportedSampleRate returns the native sampling rates,
-                                    // (the sampling rates that can be played without resampling)
-                                    // but other sampling rates can be supported by the HAL.
-                                    false))
-
-TEST_IO_STREAM(SupportedChannelMask, "Check that the stream channel mask is declared as supported",
-               testCapabilityGetter("getSupportedChannelMask", stream.get(),
-                                    &IStream::getSupportedChannelMasks, &IStream::getChannelMask,
-                                    &IStream::setChannelMask))
-
-TEST_IO_STREAM(SupportedFormat, "Check that the stream format is declared as supported",
-               testCapabilityGetter("getSupportedFormat", stream.get(),
-                                    &IStream::getSupportedFormats, &IStream::getFormat,
-                                    &IStream::setFormat))
-
-static void testGetDevice(IStream* stream, AudioDevice expectedDevice) {
-    // Unfortunately the interface does not allow the implementation to return
-    // NOT_SUPPORTED
-    // Thus allow NONE as signaling that the call is not supported.
-    auto ret = stream->getDevice();
-    ASSERT_IS_OK(ret);
-    AudioDevice device = ret;
-    ASSERT_TRUE(device == expectedDevice || device == AudioDevice::NONE)
-        << "Expected: " << ::testing::PrintToString(expectedDevice)
-        << "\n  Actual: " << ::testing::PrintToString(device);
-}
-
-TEST_IO_STREAM(GetDevice, "Check that the stream device == the one it was opened with",
-               areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
-                                          : testGetDevice(stream.get(), address.device))
-
-static void testSetDevice(IStream* stream, const DeviceAddress& address) {
-    DeviceAddress otherAddress = address;
-    otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER
-                                                                      : AudioDevice::IN_BUILTIN_MIC;
-    EXPECT_OK(stream->setDevice(otherAddress));
-
-    ASSERT_OK(stream->setDevice(address));  // Go back to the original value
-}
-
-TEST_IO_STREAM(SetDevice, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
-               areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
-                                          : testSetDevice(stream.get(), address))
-
-static void testGetAudioProperties(IStream* stream, AudioConfig expectedConfig) {
-    uint32_t sampleRateHz;
-    AudioChannelMask mask;
-    AudioFormat format;
-
-    stream->getAudioProperties(returnIn(sampleRateHz, mask, format));
-
-    // FIXME: the qcom hal it does not currently negotiate the sampleRate &
-    // channel mask
-    EXPECT_EQ(expectedConfig.sampleRateHz, sampleRateHz);
-    EXPECT_EQ(expectedConfig.channelMask, mask);
-    EXPECT_EQ(expectedConfig.format, format);
-}
-
-TEST_IO_STREAM(GetAudioProperties,
-               "Check that the stream audio properties == the ones it was opened with",
-               testGetAudioProperties(stream.get(), audioConfig))
-
-static void testConnectedState(IStream* stream) {
-    DeviceAddress address = {};
-    using AD = AudioDevice;
-    for (auto device : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) {
-        address.device = device;
-
-        ASSERT_OK(stream->setConnectedState(address, true));
-        ASSERT_OK(stream->setConnectedState(address, false));
-    }
-}
-TEST_IO_STREAM(SetConnectedState,
-               "Check that the stream can be notified of device connection and "
-               "deconnection",
-               testConnectedState(stream.get()))
-
-static auto invalidArgsOrNotSupportedOrOK = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED,
-                                             Result::OK};
-TEST_IO_STREAM(SetHwAvSync, "Try to set hardware sync to an invalid value",
-               ASSERT_RESULT(invalidArgsOrNotSupportedOrOK, stream->setHwAvSync(666)))
-
-TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", ASSERT_IS_OK(device->getHwAvSync()));
-
-static void checkGetNoParameter(IStream* stream, hidl_vec<hidl_string> keys,
-                                initializer_list<Result> expectedResults) {
-    hidl_vec<ParameterValue> parameters;
-    Result res;
-    ASSERT_OK(stream->getParameters(keys, returnIn(res, parameters)));
-    ASSERT_RESULT(expectedResults, res);
-    if (res == Result::OK) {
-        for (auto& parameter : parameters) {
-            ASSERT_EQ(0U, parameter.value.size()) << toString(parameter);
-        }
-    }
-}
-
-/* Get/Set parameter is intended to be an opaque channel between vendors app and
- * their HALs.
- * Thus can not be meaningfully tested.
- */
-TEST_IO_STREAM(getEmptySetParameter, "Retrieve the values of an empty set",
-               checkGetNoParameter(stream.get(), {} /* keys */, {Result::OK}))
-
-TEST_IO_STREAM(getNonExistingParameter, "Retrieve the values of an non existing parameter",
-               checkGetNoParameter(stream.get(), {"Non existing key"} /* keys */,
-                                   {Result::NOT_SUPPORTED}))
-
-TEST_IO_STREAM(setEmptySetParameter, "Set the values of an empty set of parameters",
-               ASSERT_RESULT(Result::OK, stream->setParameters({})))
-
-TEST_IO_STREAM(setNonExistingParameter, "Set the values of an non existing parameter",
-               // Unfortunately, the set_parameter legacy interface did not return any
-               // error code when a key is not supported.
-               // To allow implementation to just wrapped the legacy one, consider OK as a
-               // valid result for setting a non existing parameter.
-               ASSERT_RESULT(invalidArgsOrNotSupportedOrOK,
-                             stream->setParameters({{"non existing key", "0"}})))
-
-TEST_IO_STREAM(DebugDump, "Check that a stream can dump its state without error",
-               testDebugDump([this](const auto& handle) { return stream->debugDump(handle); }))
-
-TEST_IO_STREAM(DebugDumpInvalidArguments,
-               "Check that the stream dump doesn't crash on invalid arguments",
-               ASSERT_OK(stream->debugDump(hidl_handle())))
-
-//////////////////////////////////////////////////////////////////////////////
-////////////////////////////// addRemoveEffect ///////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-TEST_IO_STREAM(AddNonExistingEffect, "Adding a non existing effect should fail",
-               ASSERT_RESULT(Result::INVALID_ARGUMENTS, stream->addEffect(666)))
-TEST_IO_STREAM(RemoveNonExistingEffect, "Removing a non existing effect should fail",
-               ASSERT_RESULT(Result::INVALID_ARGUMENTS, stream->removeEffect(666)))
-
-// TODO: positive tests
-
-//////////////////////////////////////////////////////////////////////////////
-/////////////////////////////// Control ////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-TEST_IO_STREAM(standby, "Make sure the stream can be put in stanby",
-               ASSERT_OK(stream->standby()))  // can not fail
-
-static constexpr auto invalidStateOrNotSupported = {Result::INVALID_STATE, Result::NOT_SUPPORTED};
-
-TEST_IO_STREAM(startNoMmap, "Starting a mmaped stream before mapping it should fail",
-               ASSERT_RESULT(invalidStateOrNotSupported, stream->start()))
-
-TEST_IO_STREAM(stopNoMmap, "Stopping a mmaped stream before mapping it should fail",
-               ASSERT_RESULT(invalidStateOrNotSupported, stream->stop()))
-
-TEST_IO_STREAM(getMmapPositionNoMmap, "Get a stream Mmap position before mapping it should fail",
-               ASSERT_RESULT(invalidStateOrNotSupported, stream->stop()))
-
-TEST_IO_STREAM(close, "Make sure a stream can be closed", ASSERT_OK(closeStream()))
-TEST_IO_STREAM(closeTwice, "Make sure a stream can not be closed twice", ASSERT_OK(closeStream());
-               ASSERT_RESULT(Result::INVALID_STATE, closeStream()))
-
-static auto invalidArgsOrNotSupported = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED};
-static void testCreateTooBigMmapBuffer(IStream* stream) {
-    MmapBufferInfo info;
-    Result res;
-    // Assume that int max is a value too big to be allocated
-    // This is true currently with a 32bit media server, but might not when it
-    // will run in 64 bit
-    auto minSizeFrames = std::numeric_limits<int32_t>::max();
-    ASSERT_OK(stream->createMmapBuffer(minSizeFrames, returnIn(res, info)));
-    ASSERT_RESULT(invalidArgsOrNotSupported, res);
-}
-
-TEST_IO_STREAM(CreateTooBigMmapBuffer, "Create mmap buffer too big should fail",
-               testCreateTooBigMmapBuffer(stream.get()))
-
-static void testGetMmapPositionOfNonMmapedStream(IStream* stream) {
-    Result res;
-    MmapPosition position;
-    ASSERT_OK(stream->getMmapPosition(returnIn(res, position)));
-    ASSERT_RESULT(invalidArgsOrNotSupported, res);
-}
-
-TEST_IO_STREAM(GetMmapPositionOfNonMmapedStream,
-               "Retrieving the mmap position of a non mmaped stream should fail",
-               testGetMmapPositionOfNonMmapedStream(stream.get()))
-
-//////////////////////////////////////////////////////////////////////////////
-///////////////////////////////// StreamIn ///////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-TEST_P(InputStreamTest, GetAudioSource) {
-    doc::test("Retrieving the audio source of an input stream should always succeed");
-    AudioSource source;
-    ASSERT_OK(stream->getAudioSource(returnIn(res, source)));
-    if (res == Result::NOT_SUPPORTED) {
-        doc::partialTest("getAudioSource is not supported");
-        return;
-    }
-    ASSERT_OK(res);
-    ASSERT_EQ(AudioSource::DEFAULT, source);
-}
-
-static void testUnitaryGain(std::function<Return<Result>(float)> setGain) {
-    for (float value : (float[]){-INFINITY, -1.0, 1.0 + std::numeric_limits<float>::epsilon(), 2.0,
-                                 INFINITY, NAN}) {
-        EXPECT_RESULT(Result::INVALID_ARGUMENTS, setGain(value)) << "value=" << value;
-    }
-    // Do not consider -0.0 as an invalid value as it is == with 0.0
-    for (float value : {-0.0, 0.0, 0.01, 0.5, 0.09, 1.0 /* Restore volume*/}) {
-        EXPECT_OK(setGain(value)) << "value=" << value;
-    }
-}
-
-static void testOptionalUnitaryGain(std::function<Return<Result>(float)> setGain,
-                                    string debugName) {
-    auto result = setGain(1);
-    ASSERT_IS_OK(result);
-    if (result == Result::NOT_SUPPORTED) {
-        doc::partialTest(debugName + " is not supported");
-        return;
-    }
-    testUnitaryGain(setGain);
-}
-
-TEST_P(InputStreamTest, SetGain) {
-    doc::test("The gain of an input stream should only be set between [0,1]");
-    testOptionalUnitaryGain([this](float volume) { return stream->setGain(volume); },
-                            "InputStream::setGain");
-}
-
-static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize, uint32_t framesCount) {
-    Result res;
-    // Ignore output parameters as the call should fail
-    ASSERT_OK(stream->prepareForReading(frameSize, framesCount,
-                                        [&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
-    EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
-}
-
-TEST_P(InputStreamTest, PrepareForReadingWithZeroBuffer) {
-    doc::test("Preparing a stream for reading with a 0 sized buffer should fail");
-    testPrepareForReading(stream.get(), 0, 0);
-}
-
-TEST_P(InputStreamTest, PrepareForReadingWithHugeBuffer) {
-    doc::test("Preparing a stream for reading with a 2^32 sized buffer should fail");
-    testPrepareForReading(stream.get(), 1, std::numeric_limits<uint32_t>::max());
-}
-
-TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) {
-    doc::test(
-        "Preparing a stream for reading with a overflowing sized buffer should "
-        "fail");
-    auto uintMax = std::numeric_limits<uint32_t>::max();
-    testPrepareForReading(stream.get(), uintMax, uintMax);
-}
-
-TEST_P(InputStreamTest, GetInputFramesLost) {
-    doc::test("The number of frames lost on a never started stream should be 0");
-    auto ret = stream->getInputFramesLost();
-    ASSERT_IS_OK(ret);
-    uint32_t framesLost{ret};
-    ASSERT_EQ(0U, framesLost);
-}
-
-TEST_P(InputStreamTest, getCapturePosition) {
-    doc::test(
-        "The capture position of a non prepared stream should not be "
-        "retrievable");
-    uint64_t frames;
-    uint64_t time;
-    ASSERT_OK(stream->getCapturePosition(returnIn(res, frames, time)));
-    ASSERT_RESULT(invalidStateOrNotSupported, res);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-///////////////////////////////// StreamIn ///////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-TEST_P(OutputStreamTest, getLatency) {
-    doc::test("Make sure latency is over 0");
-    auto result = stream->getLatency();
-    ASSERT_IS_OK(result);
-    ASSERT_GT(result, 0U);
-}
-
-TEST_P(OutputStreamTest, setVolume) {
-    doc::test("Try to set the output volume");
-    testOptionalUnitaryGain([this](float volume) { return stream->setVolume(volume, volume); },
-                            "setVolume");
-}
-
-static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize, uint32_t framesCount) {
-    Result res;
-    // Ignore output parameters as the call should fail
-    ASSERT_OK(stream->prepareForWriting(frameSize, framesCount,
-                                        [&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
-    EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
-}
-
-TEST_P(OutputStreamTest, PrepareForWriteWithZeroBuffer) {
-    doc::test("Preparing a stream for writing with a 0 sized buffer should fail");
-    testPrepareForWriting(stream.get(), 0, 0);
-}
-
-TEST_P(OutputStreamTest, PrepareForWriteWithHugeBuffer) {
-    doc::test("Preparing a stream for writing with a 2^32 sized buffer should fail");
-    testPrepareForWriting(stream.get(), 1, std::numeric_limits<uint32_t>::max());
-}
-
-TEST_P(OutputStreamTest, PrepareForWritingCheckOverflow) {
-    doc::test(
-        "Preparing a stream for writing with a overflowing sized buffer should "
-        "fail");
-    auto uintMax = std::numeric_limits<uint32_t>::max();
-    testPrepareForWriting(stream.get(), uintMax, uintMax);
-}
-
-struct Capability {
-    Capability(IStreamOut* stream) {
-        EXPECT_OK(stream->supportsPauseAndResume(returnIn(pause, resume)));
-        auto ret = stream->supportsDrain();
-        EXPECT_IS_OK(ret);
-        if (ret.isOk()) {
-            drain = ret;
-        }
-    }
-    bool pause = false;
-    bool resume = false;
-    bool drain = false;
-};
-
-TEST_P(OutputStreamTest, SupportsPauseAndResumeAndDrain) {
-    doc::test("Implementation must expose pause, resume and drain capabilities");
-    Capability(stream.get());
-}
-
-template <class Value>
-static void checkInvalidStateOr0(Result res, Value value) {
-    switch (res) {
-        case Result::INVALID_STATE:
-            break;
-        case Result::OK:
-            ASSERT_EQ(0U, value);
-            break;
-        default:
-            FAIL() << "Unexpected result " << toString(res);
-    }
-}
-
-TEST_P(OutputStreamTest, GetRenderPosition) {
-    doc::test("A new stream render position should be 0 or INVALID_STATE");
-    uint32_t dspFrames;
-    ASSERT_OK(stream->getRenderPosition(returnIn(res, dspFrames)));
-    if (res == Result::NOT_SUPPORTED) {
-        doc::partialTest("getRenderPosition is not supported");
-        return;
-    }
-    checkInvalidStateOr0(res, dspFrames);
-}
-
-TEST_P(OutputStreamTest, GetNextWriteTimestamp) {
-    doc::test("A new stream next write timestamp should be 0 or INVALID_STATE");
-    uint64_t timestampUs;
-    ASSERT_OK(stream->getNextWriteTimestamp(returnIn(res, timestampUs)));
-    if (res == Result::NOT_SUPPORTED) {
-        doc::partialTest("getNextWriteTimestamp is not supported");
-        return;
-    }
-    checkInvalidStateOr0(res, timestampUs);
-}
-
-/** Stub implementation of out stream callback. */
-class MockOutCallbacks : public IStreamOutCallback {
-    Return<void> onWriteReady() override { return {}; }
-    Return<void> onDrainReady() override { return {}; }
-    Return<void> onError() override { return {}; }
-};
-
-static bool isAsyncModeSupported(IStreamOut* stream) {
-    auto res = stream->setCallback(new MockOutCallbacks);
-    stream->clearCallback();  // try to restore the no callback state, ignore
-                              // any error
-    auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED};
-    EXPECT_RESULT(okOrNotSupported, res);
-    return res.isOk() ? res == Result::OK : false;
-}
-
-TEST_P(OutputStreamTest, SetCallback) {
-    doc::test(
-        "If supported, registering callback for async operation should never "
-        "fail");
-    if (!isAsyncModeSupported(stream.get())) {
-        doc::partialTest("The stream does not support async operations");
-        return;
-    }
-    ASSERT_OK(stream->setCallback(new MockOutCallbacks));
-    ASSERT_OK(stream->setCallback(new MockOutCallbacks));
-}
-
-TEST_P(OutputStreamTest, clearCallback) {
-    doc::test(
-        "If supported, clearing a callback to go back to sync operation should "
-        "not fail");
-    if (!isAsyncModeSupported(stream.get())) {
-        doc::partialTest("The stream does not support async operations");
-        return;
-    }
-    // TODO: Clarify if clearing a non existing callback should fail
-    ASSERT_OK(stream->setCallback(new MockOutCallbacks));
-    ASSERT_OK(stream->clearCallback());
-}
-
-TEST_P(OutputStreamTest, Resume) {
-    doc::test(
-        "If supported, a stream should fail to resume if not previously "
-        "paused");
-    if (!Capability(stream.get()).resume) {
-        doc::partialTest("The output stream does not support resume");
-        return;
-    }
-    ASSERT_RESULT(Result::INVALID_STATE, stream->resume());
-}
-
-TEST_P(OutputStreamTest, Pause) {
-    doc::test(
-        "If supported, a stream should fail to pause if not previously "
-        "started");
-    if (!Capability(stream.get()).pause) {
-        doc::partialTest("The output stream does not support pause");
-        return;
-    }
-    ASSERT_RESULT(Result::INVALID_STATE, stream->resume());
-}
-
-static void testDrain(IStreamOut* stream, AudioDrain type) {
-    if (!Capability(stream).drain) {
-        doc::partialTest("The output stream does not support drain");
-        return;
-    }
-    ASSERT_RESULT(Result::OK, stream->drain(type));
-}
-
-TEST_P(OutputStreamTest, DrainAll) {
-    doc::test("If supported, a stream should always succeed to drain");
-    testDrain(stream.get(), AudioDrain::ALL);
-}
-
-TEST_P(OutputStreamTest, DrainEarlyNotify) {
-    doc::test("If supported, a stream should always succeed to drain");
-    testDrain(stream.get(), AudioDrain::EARLY_NOTIFY);
-}
-
-TEST_P(OutputStreamTest, FlushStop) {
-    doc::test("If supported, a stream should always succeed to flush");
-    auto ret = stream->flush();
-    ASSERT_IS_OK(ret);
-    if (ret == Result::NOT_SUPPORTED) {
-        doc::partialTest("Flush is not supported");
-        return;
-    }
-    ASSERT_OK(ret);
-}
-
-TEST_P(OutputStreamTest, GetPresentationPositionStop) {
-    doc::test(
-        "If supported, a stream should always succeed to retrieve the "
-        "presentation position");
-    uint64_t frames;
-    TimeSpec mesureTS;
-    ASSERT_OK(stream->getPresentationPosition(returnIn(res, frames, mesureTS)));
-    if (res == Result::NOT_SUPPORTED) {
-        doc::partialTest("getpresentationPosition is not supported");
-        return;
-    }
-    ASSERT_EQ(0U, frames);
-
-    if (mesureTS.tvNSec == 0 && mesureTS.tvSec == 0) {
-        // As the stream has never written a frame yet,
-        // the timestamp does not really have a meaning, allow to return 0
-        return;
-    }
-
-    // Make sure the return measure is not more than 1s old.
-    struct timespec currentTS;
-    ASSERT_EQ(0, clock_gettime(CLOCK_MONOTONIC, &currentTS)) << errno;
-
-    auto toMicroSec = [](uint64_t sec, auto nsec) { return sec * 1e+6 + nsec / 1e+3; };
-    auto currentTime = toMicroSec(currentTS.tv_sec, currentTS.tv_nsec);
-    auto mesureTime = toMicroSec(mesureTS.tvSec, mesureTS.tvNSec);
-    ASSERT_PRED2([](auto c, auto m) { return c - m < 1e+6; }, currentTime, mesureTime);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-/////////////////////////////// PrimaryDevice ////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-TEST_F(AudioPrimaryHidlTest, setVoiceVolume) {
-    doc::test("Make sure setVoiceVolume only succeed if volume is in [0,1]");
-    testUnitaryGain([](float volume) { return device->setVoiceVolume(volume); });
-}
-
-TEST_F(AudioPrimaryHidlTest, setMode) {
-    doc::test(
-        "Make sure setMode always succeeds if mode is valid "
-        "and fails otherwise");
-    // Test Invalid values
-    for (AudioMode mode : {AudioMode::INVALID, AudioMode::CURRENT, AudioMode::CNT}) {
-        SCOPED_TRACE("mode=" + toString(mode));
-        ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(mode));
-    }
-    // Test valid values
-    for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE,
-                           AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) {
-        SCOPED_TRACE("mode=" + toString(mode));
-        ASSERT_OK(device->setMode(mode));
-    }
-}
-
-TEST_F(BoolAccessorPrimaryHidlTest, BtScoNrecEnabled) {
-    doc::test("Query and set the BT SCO NR&EC state");
-    testOptionalAccessors("BtScoNrecEnabled", {true, false, true},
-                          &IPrimaryDevice::setBtScoNrecEnabled,
-                          &IPrimaryDevice::getBtScoNrecEnabled);
-}
-
-TEST_F(BoolAccessorPrimaryHidlTest, setGetBtScoWidebandEnabled) {
-    doc::test("Query and set the SCO whideband state");
-    testOptionalAccessors("BtScoWideband", {true, false, true},
-                          &IPrimaryDevice::setBtScoWidebandEnabled,
-                          &IPrimaryDevice::getBtScoWidebandEnabled);
-}
-
-using TtyModeAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<TtyMode>;
-TEST_F(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) {
-    doc::test("Query and set the TTY mode state");
-    testOptionalAccessors("TTY mode", {TtyMode::OFF, TtyMode::HCO, TtyMode::VCO, TtyMode::FULL},
-                          &IPrimaryDevice::setTtyMode, &IPrimaryDevice::getTtyMode);
-}
-
-TEST_F(BoolAccessorPrimaryHidlTest, setGetHac) {
-    doc::test("Query and set the HAC state");
-    testOptionalAccessors("HAC", {true, false, true}, &IPrimaryDevice::setHacEnabled,
-                          &IPrimaryDevice::getHacEnabled);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////// Clean caches on global tear down ////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-int main(int argc, char** argv) {
-    environment = new AudioHidlTestEnvironment;
-    ::testing::AddGlobalTestEnvironment(environment);
-    ::testing::InitGoogleTest(&argc, argv);
-    environment->init(&argc, argv);
-    int status = RUN_ALL_TESTS();
-    return status;
-}
diff --git a/audio/core/2.0/vts/functional/ValidateAudioConfiguration.cpp b/audio/core/2.0/vts/functional/ValidateAudioConfiguration.cpp
deleted file mode 100644
index bef0e82..0000000
--- a/audio/core/2.0/vts/functional/ValidateAudioConfiguration.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <unistd.h>
-#include <string>
-
-#include "utility/ValidateXml.h"
-
-TEST(CheckConfig, audioPolicyConfigurationValidation) {
-    RecordProperty("description",
-                   "Verify that the audio policy configuration file "
-                   "is valid according to the schema");
-
-    std::vector<const char*> locations = {"/odm/etc", "/vendor/etc", "/system/etc"};
-    EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS("audio_policy_configuration.xml", locations,
-                                            "/data/local/tmp/audio_policy_configuration.xsd");
-}
diff --git a/audio/core/4.0/default/Android.bp b/audio/core/4.0/default/Android.bp
deleted file mode 100644
index 8e41545..0000000
--- a/audio/core/4.0/default/Android.bp
+++ /dev/null
@@ -1,53 +0,0 @@
-cc_library_shared {
-    name: "android.hardware.audio@4.0-impl",
-    relative_install_path: "hw",
-    proprietary: true,
-    vendor: true,
-    srcs: [
-        "Conversions.cpp",
-        "Device.cpp",
-        "DevicesFactory.cpp",
-        "ParametersUtil.cpp",
-        "PrimaryDevice.cpp",
-        "Stream.cpp",
-        "StreamIn.cpp",
-        "StreamOut.cpp",
-    ],
-
-    cflags: [
-        "-DAUDIO_HAL_VERSION_4_0",
-    ],
-
-    defaults: ["hidl_defaults"],
-
-    export_include_dirs: ["include"],
-
-    shared_libs: [
-        "libbase",
-        "libcutils",
-        "libfmq",
-        "libhardware",
-        "libhidlbase",
-        "libhidltransport",
-        "liblog",
-        "libutils",
-        "android.hardware.audio@4.0",
-        "android.hardware.audio.common@4.0",
-        "android.hardware.audio.common@4.0-util",
-        "android.hardware.audio.common-util",
-    ],
-
-    header_libs: [
-        "android.hardware.audio.common.util@all-versions",
-        "android.hardware.audio.core@all-versions-impl",
-        "libaudioclient_headers",
-        "libaudio_system_headers",
-        "libhardware_headers",
-        "libmedia_headers",
-    ],
-
-    whole_static_libs: [
-        "libmedia_helper",
-    ],
-
-}
diff --git a/audio/core/4.0/default/Conversions.cpp b/audio/core/4.0/default/Conversions.cpp
deleted file mode 100644
index 4f18744..0000000
--- a/audio/core/4.0/default/Conversions.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "core/4.0/default/Conversions.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/Conversions.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/4.0/default/Device.cpp b/audio/core/4.0/default/Device.cpp
deleted file mode 100644
index b33434e..0000000
--- a/audio/core/4.0/default/Device.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "DeviceHAL"
-
-#include "core/4.0/default/Device.h"
-#include <HidlUtils.h>
-#include "core/4.0/default/Conversions.h"
-#include "core/4.0/default/StreamIn.h"
-#include "core/4.0/default/StreamOut.h"
-#include "core/4.0/default/Util.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/Device.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/4.0/default/DevicesFactory.cpp b/audio/core/4.0/default/DevicesFactory.cpp
deleted file mode 100644
index cb8a3c3..0000000
--- a/audio/core/4.0/default/DevicesFactory.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "DevicesFactoryHAL"
-
-#include "core/4.0/default/DevicesFactory.h"
-#include "core/4.0/default/Device.h"
-#include "core/4.0/default/PrimaryDevice.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/DevicesFactory.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/4.0/default/OWNERS b/audio/core/4.0/default/OWNERS
deleted file mode 100644
index 6fdc97c..0000000
--- a/audio/core/4.0/default/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-elaurent@google.com
-krocard@google.com
-mnaganov@google.com
diff --git a/audio/core/4.0/default/ParametersUtil.cpp b/audio/core/4.0/default/ParametersUtil.cpp
deleted file mode 100644
index 2cc9fb5..0000000
--- a/audio/core/4.0/default/ParametersUtil.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "core/4.0/default/ParametersUtil.h"
-#include "core/4.0/default/Util.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/ParametersUtil.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/4.0/default/PrimaryDevice.cpp b/audio/core/4.0/default/PrimaryDevice.cpp
deleted file mode 100644
index e3e4976..0000000
--- a/audio/core/4.0/default/PrimaryDevice.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "PrimaryDeviceHAL"
-
-#include "core/4.0/default/PrimaryDevice.h"
-#include "core/4.0/default/Util.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/PrimaryDevice.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/4.0/default/Stream.cpp b/audio/core/4.0/default/Stream.cpp
deleted file mode 100644
index b8c71de..0000000
--- a/audio/core/4.0/default/Stream.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "StreamHAL"
-
-#include "core/4.0/default/Stream.h"
-#include "common/all-versions/default/EffectMap.h"
-#include "core/4.0/default/Conversions.h"
-#include "core/4.0/default/Util.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/Stream.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/4.0/default/StreamIn.cpp b/audio/core/4.0/default/StreamIn.cpp
deleted file mode 100644
index 718bd25..0000000
--- a/audio/core/4.0/default/StreamIn.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "StreamInHAL"
-
-#include "core/4.0/default/StreamIn.h"
-#include "core/4.0/default/Util.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/StreamIn.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/4.0/default/StreamOut.cpp b/audio/core/4.0/default/StreamOut.cpp
deleted file mode 100644
index db88e40..0000000
--- a/audio/core/4.0/default/StreamOut.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "StreamOutHAL"
-
-#include "core/4.0/default/StreamOut.h"
-#include "core/4.0/default/Util.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/StreamOut.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/core/4.0/default/include/core/4.0/default/Conversions.h b/audio/core/4.0/default/include/core/4.0/default/Conversions.h
deleted file mode 100644
index 32c2f88..0000000
--- a/audio/core/4.0/default/include/core/4.0/default/Conversions.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V4_0_CONVERSIONS_H_
-#define ANDROID_HARDWARE_AUDIO_V4_0_CONVERSIONS_H_
-
-#include <android/hardware/audio/4.0/types.h>
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/Conversions.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V4_0_CONVERSIONS_H_
diff --git a/audio/core/4.0/default/include/core/4.0/default/Device.h b/audio/core/4.0/default/include/core/4.0/default/Device.h
deleted file mode 100644
index 770d606..0000000
--- a/audio/core/4.0/default/include/core/4.0/default/Device.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V4_0_DEVICE_H
-#define ANDROID_HARDWARE_AUDIO_V4_0_DEVICE_H
-
-#include <android/hardware/audio/4.0/IDevice.h>
-
-#include "ParametersUtil.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/Device.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V4_0_DEVICE_H
diff --git a/audio/core/4.0/default/include/core/4.0/default/DevicesFactory.h b/audio/core/4.0/default/include/core/4.0/default/DevicesFactory.h
deleted file mode 100644
index 200e59d..0000000
--- a/audio/core/4.0/default/include/core/4.0/default/DevicesFactory.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V4_0_DEVICESFACTORY_H
-#define ANDROID_HARDWARE_AUDIO_V4_0_DEVICESFACTORY_H
-
-#include <android/hardware/audio/4.0/IDevicesFactory.h>
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/DevicesFactory.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V4_0_DEVICESFACTORY_H
diff --git a/audio/core/4.0/default/include/core/4.0/default/ParametersUtil.h b/audio/core/4.0/default/include/core/4.0/default/ParametersUtil.h
deleted file mode 100644
index fa31ee9..0000000
--- a/audio/core/4.0/default/include/core/4.0/default/ParametersUtil.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V4_0_PARAMETERS_UTIL_H_
-#define ANDROID_HARDWARE_AUDIO_V4_0_PARAMETERS_UTIL_H_
-
-#include <android/hardware/audio/4.0/types.h>
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/ParametersUtil.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V4_0_PARAMETERS_UTIL_H_
diff --git a/audio/core/4.0/default/include/core/4.0/default/PrimaryDevice.h b/audio/core/4.0/default/include/core/4.0/default/PrimaryDevice.h
deleted file mode 100644
index e7f846b..0000000
--- a/audio/core/4.0/default/include/core/4.0/default/PrimaryDevice.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V4_0_PRIMARYDEVICE_H
-#define ANDROID_HARDWARE_AUDIO_V4_0_PRIMARYDEVICE_H
-
-#include <android/hardware/audio/4.0/IPrimaryDevice.h>
-
-#include "Device.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/PrimaryDevice.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V4_0_PRIMARYDEVICE_H
diff --git a/audio/core/4.0/default/include/core/4.0/default/Stream.h b/audio/core/4.0/default/include/core/4.0/default/Stream.h
deleted file mode 100644
index afad80f..0000000
--- a/audio/core/4.0/default/include/core/4.0/default/Stream.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V4_0_STREAM_H
-#define ANDROID_HARDWARE_AUDIO_V4_0_STREAM_H
-
-#include <android/hardware/audio/4.0/IStream.h>
-
-#include "ParametersUtil.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/Stream.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V4_0_STREAM_H
diff --git a/audio/core/4.0/default/include/core/4.0/default/StreamIn.h b/audio/core/4.0/default/include/core/4.0/default/StreamIn.h
deleted file mode 100644
index 151f03f..0000000
--- a/audio/core/4.0/default/include/core/4.0/default/StreamIn.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V4_0_STREAMIN_H
-#define ANDROID_HARDWARE_AUDIO_V4_0_STREAMIN_H
-
-#include <android/hardware/audio/4.0/IStreamIn.h>
-
-#include "Device.h"
-#include "Stream.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/StreamIn.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V4_0_STREAMIN_H
diff --git a/audio/core/4.0/default/include/core/4.0/default/StreamOut.h b/audio/core/4.0/default/include/core/4.0/default/StreamOut.h
deleted file mode 100644
index dbf3bd1..0000000
--- a/audio/core/4.0/default/include/core/4.0/default/StreamOut.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V4_0_STREAMOUT_H
-#define ANDROID_HARDWARE_AUDIO_V4_0_STREAMOUT_H
-
-#include <android/hardware/audio/4.0/IStreamOut.h>
-
-#include "Device.h"
-#include "Stream.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/StreamOut.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V4_0_STREAMOUT_H
diff --git a/audio/core/4.0/default/include/core/4.0/default/Util.h b/audio/core/4.0/default/include/core/4.0/default/Util.h
deleted file mode 100644
index ce31e6f..0000000
--- a/audio/core/4.0/default/include/core/4.0/default/Util.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_V4_0_UTIL_H
-#define ANDROID_HARDWARE_AUDIO_V4_0_UTIL_H
-
-#include <android/hardware/audio/4.0/types.h>
-
-#define AUDIO_HAL_VERSION V4_0
-#include <core/all-versions/default/Util.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_V4_0_UTIL_H
diff --git a/audio/core/4.0/vts/OWNERS b/audio/core/4.0/vts/OWNERS
deleted file mode 100644
index 8711a9f..0000000
--- a/audio/core/4.0/vts/OWNERS
+++ /dev/null
@@ -1,5 +0,0 @@
-elaurent@google.com
-krocard@google.com
-mnaganov@google.com
-yim@google.com
-zhuoyao@google.com
\ No newline at end of file
diff --git a/audio/core/4.0/vts/functional/Android.bp b/audio/core/4.0/vts/functional/Android.bp
deleted file mode 100644
index e3b376c..0000000
--- a/audio/core/4.0/vts/functional/Android.bp
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Copyright (C) 2017 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-cc_test {
-    name: "VtsHalAudioV4_0TargetTest",
-    defaults: ["VtsHalTargetTestDefaults"],
-    srcs: [
-        "AudioPrimaryHidlHalTest.cpp",
-        "ValidateAudioConfiguration.cpp"
-    ],
-    static_libs: [
-        "android.hardware.audio.common.test.utility",
-        "android.hardware.audio@4.0",
-        "android.hardware.audio.common@4.0",
-        "libicuuc",
-        "libicuuc_stubdata",
-        "libxml2",
-    ],
-    shared_libs: [
-        "libfmq",
-    ],
-    header_libs: [
-        "android.hardware.audio.common.util@all-versions",
-    ],
-}
diff --git a/audio/core/4.0/vts/functional/ValidateAudioConfiguration.cpp b/audio/core/4.0/vts/functional/ValidateAudioConfiguration.cpp
deleted file mode 100644
index a64513f..0000000
--- a/audio/core/4.0/vts/functional/ValidateAudioConfiguration.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <unistd.h>
-#include <string>
-
-#include "utility/ValidateXml.h"
-
-TEST(CheckConfig, audioPolicyConfigurationValidation) {
-    RecordProperty("description",
-                   "Verify that the audio policy configuration file "
-                   "is valid according to the schema");
-
-    std::vector<const char*> locations = {"/odm/etc", "/vendor/etc", "/system/etc"};
-    EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS("audio_policy_configuration.xml", locations,
-                                            "/data/local/tmp/audio_policy_configuration_V4_0.xsd");
-}
diff --git a/audio/core/all-versions/default/Android.bp b/audio/core/all-versions/default/Android.bp
index bb02863..a1af3c4 100644
--- a/audio/core/all-versions/default/Android.bp
+++ b/audio/core/all-versions/default/Android.bp
@@ -1,7 +1,18 @@
-cc_library_headers {
-    name: "android.hardware.audio.core@all-versions-impl",
+cc_defaults {
+    name: "android.hardware.audio-impl_default",
     relative_install_path: "hw",
+    proprietary: true,
     vendor: true,
+    srcs: [
+        "Conversions.cpp",
+        "Device.cpp",
+        "DevicesFactory.cpp",
+        "ParametersUtil.cpp",
+        "PrimaryDevice.cpp",
+        "Stream.cpp",
+        "StreamIn.cpp",
+        "StreamOut.cpp",
+    ],
 
     defaults: ["hidl_defaults"],
 
@@ -20,10 +31,65 @@
     ],
 
     header_libs: [
+        "android.hardware.audio.common.util@all-versions",
         "libaudioclient_headers",
         "libaudio_system_headers",
         "libhardware_headers",
         "libmedia_headers",
-         "android.hardware.audio.common.util@all-versions",
     ],
+
+    whole_static_libs: [
+        "libmedia_helper",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.audio@2.0-impl",
+    defaults: ["android.hardware.audio-impl_default"],
+
+    shared_libs: [
+        "android.hardware.audio@2.0",
+        "android.hardware.audio.common@2.0",
+        "android.hardware.audio.common@2.0-util",
+    ],
+
+    cflags: [
+        "-DMAJOR_VERSION=2",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
+
+cc_library_shared {
+    name: "android.hardware.audio@4.0-impl",
+    defaults: ["android.hardware.audio-impl_default"],
+
+    shared_libs: [
+        "android.hardware.audio@4.0",
+        "android.hardware.audio.common@4.0",
+        "android.hardware.audio.common@4.0-util",
+    ],
+
+    cflags: [
+        "-DMAJOR_VERSION=4",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
+
+cc_library_shared {
+    name: "android.hardware.audio@5.0-impl",
+    defaults: ["android.hardware.audio-impl_default"],
+
+    shared_libs: [
+        "android.hardware.audio@5.0",
+        "android.hardware.audio.common@5.0",
+        "android.hardware.audio.common@5.0-util",
+    ],
+
+    cflags: [
+        "-DMAJOR_VERSION=5",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
 }
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Conversions.impl.h b/audio/core/all-versions/default/Conversions.cpp
similarity index 96%
rename from audio/core/all-versions/default/include/core/all-versions/default/Conversions.impl.h
rename to audio/core/all-versions/default/Conversions.cpp
index 5828c3f..b1e6c60 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/Conversions.impl.h
+++ b/audio/core/all-versions/default/Conversions.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#include "core/default/Conversions.h"
 
 #include <stdio.h>
 
@@ -23,10 +23,10 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
 
 std::string deviceAddressToHal(const DeviceAddress& address) {
     // HAL assumes that the address is NUL-terminated.
@@ -58,7 +58,7 @@
     return halAddress;
 }
 
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
 status_t deviceAddressFromHal(audio_devices_t device, const char* halAddress,
                               DeviceAddress* address) {
     if (address == nullptr) {
@@ -188,7 +188,7 @@
 #endif
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h b/audio/core/all-versions/default/Device.cpp
similarity index 94%
rename from audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h
rename to audio/core/all-versions/default/Device.cpp
index 52d2186..6a04903 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h
+++ b/audio/core/all-versions/default/Device.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,14 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "DeviceHAL"
+
+#include "core/default/Device.h"
+#include <HidlUtils.h>
+#include "core/default/Conversions.h"
+#include "core/default/StreamIn.h"
+#include "core/default/StreamOut.h"
+#include "core/default/Util.h"
 
 //#define LOG_NDEBUG 0
 
@@ -24,12 +31,12 @@
 
 #include <android/log.h>
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::HidlUtils;
+using ::android::hardware::audio::common::CPP_VERSION::HidlUtils;
 
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 Device::Device(audio_hw_device_t* device) : mDevice(device) {}
@@ -61,7 +68,7 @@
     return mDevice->set_parameters(mDevice, keysAndValues);
 }
 
-// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice follow.
+// Methods from ::android::hardware::audio::CPP_VERSION::IDevice follow.
 Return<Result> Device::initCheck() {
     return analyzeStatus("init_check", mDevice->init_check(mDevice));
 }
@@ -132,7 +139,7 @@
 
 Return<void> Device::openOutputStream(int32_t ioHandle, const DeviceAddress& device,
                                       const AudioConfig& config, AudioOutputFlagBitfield flags,
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
                                       const SourceMetadata& /* sourceMetadata */,
 #endif
                                       openOutputStream_cb _hidl_cb) {
@@ -190,7 +197,7 @@
     return Void();
 }
 
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
 Return<void> Device::openInputStream(int32_t ioHandle, const DeviceAddress& device,
                                      const AudioConfig& config, AudioInputFlagBitfield flags,
                                      const SinkMetadata& sinkMetadata,
@@ -263,13 +270,13 @@
     return Result::NOT_SUPPORTED;
 }
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<AudioHwSync> Device::getHwAvSync() {
     int halHwAvSync;
     Result retval = getParam(AudioParameter::keyHwAvSync, &halHwAvSync);
     return retval == Result::OK ? halHwAvSync : AUDIO_HW_SYNC_INVALID;
 }
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
 Return<void> Device::getHwAvSync(getHwAvSync_cb _hidl_cb) {
     int halHwAvSync;
     Result retval = getParam(AudioParameter::keyHwAvSync, &halHwAvSync);
@@ -282,7 +289,7 @@
     return setParam(AudioParameter::keyScreenState, turnedOn);
 }
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<void> Device::getParameters(const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) {
     getParametersImpl({}, keys, _hidl_cb);
     return Void();
@@ -291,7 +298,7 @@
 Return<Result> Device::setParameters(const hidl_vec<ParameterValue>& parameters) {
     return setParametersImpl({} /* context */, parameters);
 }
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
 Return<void> Device::getParameters(const hidl_vec<ParameterValue>& context,
                                    const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) {
     getParametersImpl(context, keys, _hidl_cb);
@@ -303,7 +310,7 @@
 }
 #endif
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<void> Device::debugDump(const hidl_handle& fd) {
     return debug(fd, {});
 }
@@ -316,7 +323,7 @@
     return Void();
 }
 
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
 Return<void> Device::getMicrophones(getMicrophones_cb _hidl_cb) {
     Result retval = Result::NOT_SUPPORTED;
     size_t actual_mics = AUDIO_MICROPHONE_MAX_COUNT;
@@ -342,7 +349,7 @@
 #endif
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.impl.h b/audio/core/all-versions/default/DevicesFactory.cpp
similarity index 91%
rename from audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.impl.h
rename to audio/core/all-versions/default/DevicesFactory.cpp
index a9f59fb..729f18c 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.impl.h
+++ b/audio/core/all-versions/default/DevicesFactory.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,11 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "DevicesFactoryHAL"
+
+#include "core/default/DevicesFactory.h"
+#include "core/default/Device.h"
+#include "core/default/PrimaryDevice.h"
 
 #include <string.h>
 
@@ -23,10 +27,10 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<void> DevicesFactory::openDevice(IDevicesFactory::Device device, openDevice_cb _hidl_cb) {
     switch (device) {
         case IDevicesFactory::Device::PRIMARY:
@@ -43,8 +47,7 @@
     _hidl_cb(Result::INVALID_ARGUMENTS, nullptr);
     return Void();
 }
-#endif
-#ifdef AUDIO_HAL_VERSION_4_0
+#elif MAJOR_VERSION >= 4
 Return<void> DevicesFactory::openDevice(const hidl_string& moduleName, openDevice_cb _hidl_cb) {
     if (moduleName == AUDIO_HARDWARE_MODULE_ID_PRIMARY) {
         return openDevice<PrimaryDevice>(moduleName.c_str(), _hidl_cb);
@@ -111,7 +114,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
diff --git a/audio/core/all-versions/OWNERS b/audio/core/all-versions/default/OWNERS
similarity index 100%
rename from audio/core/all-versions/OWNERS
rename to audio/core/all-versions/default/OWNERS
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.impl.h b/audio/core/all-versions/default/ParametersUtil.cpp
similarity index 95%
rename from audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.impl.h
rename to audio/core/all-versions/default/ParametersUtil.cpp
index 34bc53c..0c8e28a 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.impl.h
+++ b/audio/core/all-versions/default/ParametersUtil.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,14 +14,16 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
-#include <core/all-versions/default/Conversions.h>
+#include "core/default/ParametersUtil.h"
+#include "core/default/Conversions.h"
+#include "core/default/Util.h"
+
 #include <system/audio.h>
 
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 /** Converts a status_t in Result according to the rules of AudioParameter::get*
@@ -159,7 +161,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h b/audio/core/all-versions/default/PrimaryDevice.cpp
similarity index 94%
rename from audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h
rename to audio/core/all-versions/default/PrimaryDevice.cpp
index f269dd4..99590b0 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h
+++ b/audio/core/all-versions/default/PrimaryDevice.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,23 +14,26 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "PrimaryDeviceHAL"
 
-#ifdef AUDIO_HAL_VERSION_4_0
+#include "core/default/PrimaryDevice.h"
+#include "core/default/Util.h"
+
+#if MAJOR_VERSION >= 4
 #include <cmath>
 #endif
 
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 PrimaryDevice::PrimaryDevice(audio_hw_device_t* device) : mDevice(new Device(device)) {}
 
 PrimaryDevice::~PrimaryDevice() {}
 
-// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice follow.
+// Methods from ::android::hardware::audio::CPP_VERSION::IDevice follow.
 Return<Result> PrimaryDevice::initCheck() {
     return mDevice->initCheck();
 }
@@ -64,7 +67,7 @@
     return mDevice->getInputBufferSize(config, _hidl_cb);
 }
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<void> PrimaryDevice::openOutputStream(int32_t ioHandle, const DeviceAddress& device,
                                              const AudioConfig& config,
                                              AudioOutputFlagBitfield flags,
@@ -77,7 +80,7 @@
                                             AudioSource source, openInputStream_cb _hidl_cb) {
     return mDevice->openInputStream(ioHandle, device, config, flags, source, _hidl_cb);
 }
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
 Return<void> PrimaryDevice::openOutputStream(int32_t ioHandle, const DeviceAddress& device,
                                              const AudioConfig& config,
                                              AudioOutputFlagBitfield flags,
@@ -120,7 +123,7 @@
     return mDevice->setScreenState(turnedOn);
 }
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<AudioHwSync> PrimaryDevice::getHwAvSync() {
     return mDevice->getHwAvSync();
 }
@@ -137,7 +140,7 @@
 Return<void> PrimaryDevice::debugDump(const hidl_handle& fd) {
     return mDevice->debugDump(fd);
 }
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
 Return<void> PrimaryDevice::getHwAvSync(getHwAvSync_cb _hidl_cb) {
     return mDevice->getHwAvSync(_hidl_cb);
 }
@@ -158,7 +161,7 @@
 }
 #endif
 
-// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IPrimaryDevice follow.
+// Methods from ::android::hardware::audio::CPP_VERSION::IPrimaryDevice follow.
 Return<Result> PrimaryDevice::setVoiceVolume(float volume) {
     if (!isGainNormalized(volume)) {
         ALOGW("Can not set a voice volume (%f) outside [0,1]", volume);
@@ -271,7 +274,7 @@
     return mDevice->setParam(AUDIO_PARAMETER_KEY_HAC, enabled);
 }
 
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
 Return<Result> PrimaryDevice::setBtScoHeadsetDebugName(const hidl_string& name) {
     return mDevice->setParam(AUDIO_PARAMETER_KEY_BT_SCO_HEADSET_NAME, name.c_str());
 }
@@ -307,7 +310,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h b/audio/core/all-versions/default/Stream.cpp
similarity index 94%
rename from audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h
rename to audio/core/all-versions/default/Stream.cpp
index 72d7a37..b995657 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h
+++ b/audio/core/all-versions/default/Stream.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "StreamHAL"
+
+#include "core/default/Stream.h"
+#include "common/all-versions/default/EffectMap.h"
+#include "core/default/Conversions.h"
+#include "core/default/Util.h"
 
 #include <inttypes.h>
 
@@ -28,7 +33,7 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 Stream::Stream(audio_stream_t* stream) : mStream(stream) {}
@@ -42,7 +47,6 @@
     return util::analyzeStatus("stream", funcName, status);
 }
 
-
 // static
 Result Stream::analyzeStatus(const char* funcName, int status,
                              const std::vector<int>& ignoreErrors) {
@@ -57,7 +61,7 @@
     return mStream->set_parameters(mStream, keysAndValues);
 }
 
-// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStream follow.
+// Methods from ::android::hardware::audio::CPP_VERSION::IStream follow.
 Return<uint64_t> Stream::getFrameSize() {
     // Needs to be implemented by interface subclasses. But can't be declared as pure virtual,
     // since interface subclasses implementation do not inherit from this class.
@@ -79,7 +83,7 @@
     return mStream->get_sample_rate(mStream);
 }
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<void> Stream::getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) {
     return getSupportedSampleRates(getFormat(), _hidl_cb);
 }
@@ -107,9 +111,9 @@
             result = Result::NOT_SUPPORTED;
         }
     }
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     _hidl_cb(sampleRates);
-#elif AUDIO_HAL_VERSION_4_0
+#elif MAJOR_VERSION >= 4
     _hidl_cb(result, sampleRates);
 #endif
     return Void();
@@ -136,9 +140,9 @@
             result = Result::NOT_SUPPORTED;
         }
     }
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     _hidl_cb(channelMasks);
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
     _hidl_cb(result, channelMasks);
 #endif
     return Void();
@@ -217,7 +221,7 @@
     return setParam(AudioParameter::keyStreamHwAvSync, static_cast<int>(hwAvSync));
 }
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<AudioDevice> Stream::getDevice() {
     int device = 0;
     Result retval = getParam(AudioParameter::keyRouting, &device);
@@ -242,7 +246,7 @@
         connected ? AudioParameter::keyStreamConnect : AudioParameter::keyStreamDisconnect,
         address);
 }
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
 Return<void> Stream::getDevices(getDevices_cb _hidl_cb) {
     int device = 0;
     Result retval = getParam(AudioParameter::keyRouting, &device);
@@ -314,14 +318,14 @@
     return Void();
 }
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<void> Stream::debugDump(const hidl_handle& fd) {
     return debug(fd, {} /* options */);
 }
 #endif
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h b/audio/core/all-versions/default/StreamIn.cpp
similarity index 95%
rename from audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h
rename to audio/core/all-versions/default/StreamIn.cpp
index 64c85ab..8446382 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h
+++ b/audio/core/all-versions/default/StreamIn.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,11 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "StreamInHAL"
+
+#include "core/default/StreamIn.h"
+#include "core/default/Conversions.h"
+#include "core/default/Util.h"
 
 //#define LOG_NDEBUG 0
 #define ATRACE_TAG ATRACE_TAG_AUDIO
@@ -24,17 +28,15 @@
 #include <utils/Trace.h>
 #include <memory>
 
-using ::android::hardware::audio::AUDIO_HAL_VERSION::MessageQueueFlagBits;
-#include "Conversions.h"
+using ::android::hardware::audio::common::CPP_VERSION::ThreadInfo;
+using ::android::hardware::audio::CPP_VERSION::MessageQueueFlagBits;
 
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::ThreadInfo;
-
 namespace {
 
 class ReadThread : public Thread {
@@ -162,7 +164,7 @@
     mStream = nullptr;
 }
 
-// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStream follow.
+// Methods from ::android::hardware::audio::CPP_VERSION::IStream follow.
 Return<uint64_t> StreamIn::getFrameSize() {
     return audio_stream_in_frame_size(mStream);
 }
@@ -179,7 +181,7 @@
     return mStreamCommon->getSampleRate();
 }
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<void> StreamIn::getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) {
     return mStreamCommon->getSupportedChannelMasks(_hidl_cb);
 }
@@ -241,7 +243,7 @@
     return mStreamCommon->setHwAvSync(hwAvSync);
 }
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<Result> StreamIn::setConnectedState(const DeviceAddress& address, bool connected) {
     return mStreamCommon->setConnectedState(address, connected);
 }
@@ -265,7 +267,7 @@
 Return<void> StreamIn::debugDump(const hidl_handle& fd) {
     return mStreamCommon->debugDump(fd);
 }
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
 Return<void> StreamIn::getDevices(getDevices_cb _hidl_cb) {
     return mStreamCommon->getDevices(_hidl_cb);
 }
@@ -313,7 +315,7 @@
     return Result::OK;
 }
 
-// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamIn follow.
+// Methods from ::android::hardware::audio::CPP_VERSION::IStreamIn follow.
 Return<void> StreamIn::getAudioSource(getAudioSource_cb _hidl_cb) {
     int halSource;
     Result retval = mStreamCommon->getParam(AudioParameter::keyInputSource, &halSource);
@@ -342,7 +344,6 @@
     auto sendError = [&threadInfo, &_hidl_cb](Result result) {
         _hidl_cb(result, CommandMQ::Descriptor(), DataMQ::Descriptor(), StatusMQ::Descriptor(),
                  threadInfo);
-
     };
 
     // Create message queues.
@@ -448,7 +449,7 @@
     return mStreamCommon->debug(fd, options);
 }
 
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
 Return<void> StreamIn::updateSinkMetadata(const SinkMetadata& sinkMetadata) {
     if (mStream->update_sink_metadata == nullptr) {
         return Void();  // not supported by the HAL
@@ -460,7 +461,8 @@
             {.source = static_cast<audio_source_t>(metadata.source), .gain = metadata.gain});
     }
     const sink_metadata_t halMetadata = {
-        .track_count = halTracks.size(), .tracks = halTracks.data(),
+        .track_count = halTracks.size(),
+        .tracks = halTracks.data(),
     };
     mStream->update_sink_metadata(mStream, &halMetadata);
     return Void();
@@ -487,7 +489,7 @@
 #endif
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h b/audio/core/all-versions/default/StreamOut.cpp
similarity index 96%
rename from audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h
rename to audio/core/all-versions/default/StreamOut.cpp
index 6fb157f..3a75948 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h
+++ b/audio/core/all-versions/default/StreamOut.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "StreamOutHAL"
+
+#include "core/default/StreamOut.h"
+#include "core/default/Util.h"
 
 //#define LOG_NDEBUG 0
 #define ATRACE_TAG ATRACE_TAG_AUDIO
@@ -28,10 +31,10 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::ThreadInfo;
+using ::android::hardware::audio::common::CPP_VERSION::ThreadInfo;
 
 namespace {
 
@@ -165,7 +168,7 @@
     mStream = nullptr;
 }
 
-// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStream follow.
+// Methods from ::android::hardware::audio::CPP_VERSION::IStream follow.
 Return<uint64_t> StreamOut::getFrameSize() {
     return audio_stream_out_frame_size(mStream);
 }
@@ -182,7 +185,7 @@
     return mStreamCommon->getSampleRate();
 }
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<void> StreamOut::getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) {
     return mStreamCommon->getSupportedChannelMasks(_hidl_cb);
 }
@@ -244,7 +247,7 @@
     return mStreamCommon->setHwAvSync(hwAvSync);
 }
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
 Return<Result> StreamOut::setConnectedState(const DeviceAddress& address, bool connected) {
     return mStreamCommon->setConnectedState(address, connected);
 }
@@ -269,7 +272,7 @@
 Return<void> StreamOut::debugDump(const hidl_handle& fd) {
     return mStreamCommon->debugDump(fd);
 }
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
 Return<void> StreamOut::getDevices(getDevices_cb _hidl_cb) {
     return mStreamCommon->getDevices(_hidl_cb);
 }
@@ -301,7 +304,7 @@
     return Result::OK;
 }
 
-// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOut follow.
+// Methods from ::android::hardware::audio::CPP_VERSION::IStreamOut follow.
 Return<uint32_t> StreamOut::getLatency() {
     return mStream->get_latency(mStream);
 }
@@ -326,7 +329,6 @@
     auto sendError = [&threadInfo, &_hidl_cb](Result result) {
         _hidl_cb(result, CommandMQ::Descriptor(), DataMQ::Descriptor(), StatusMQ::Descriptor(),
                  threadInfo);
-
     };
 
     // Create message queues.
@@ -545,7 +547,7 @@
     return mStreamCommon->debug(fd, options);
 }
 
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
 Return<void> StreamOut::updateSourceMetadata(const SourceMetadata& sourceMetadata) {
     if (mStream->update_source_metadata == nullptr) {
         return Void();  // not supported by the HAL
@@ -560,7 +562,8 @@
         });
     }
     const source_metadata_t halMetadata = {
-        .track_count = halTracks.size(), .tracks = halTracks.data(),
+        .track_count = halTracks.size(),
+        .tracks = halTracks.data(),
     };
     mStream->update_source_metadata(mStream, &halMetadata);
     return Void();
@@ -571,7 +574,7 @@
 #endif
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Conversions.h b/audio/core/all-versions/default/include/core/default/Conversions.h
similarity index 72%
rename from audio/core/all-versions/default/include/core/all-versions/default/Conversions.h
rename to audio/core/all-versions/default/include/core/default/Conversions.h
index b38eca3..2c33c6b 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/Conversions.h
+++ b/audio/core/all-versions/default/include/core/default/Conversions.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_CONVERSIONS_H_
+#define ANDROID_HARDWARE_AUDIO_CONVERSIONS_H_
+
+#include PATH(android/hardware/audio/FILE_VERSION/types.h)
 
 #include <string>
 
@@ -23,20 +26,22 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress;
+using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
 
 std::string deviceAddressToHal(const DeviceAddress& address);
 
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
 bool halToMicrophoneCharacteristics(MicrophoneInfo* pDst,
                                     const struct audio_microphone_characteristic_t& src);
 #endif
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_CONVERSIONS_H_
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Device.h b/audio/core/all-versions/default/include/core/default/Device.h
similarity index 73%
rename from audio/core/all-versions/default/include/core/all-versions/default/Device.h
rename to audio/core/all-versions/default/include/core/default/Device.h
index 222d3de..9975d5b 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/Device.h
+++ b/audio/core/all-versions/default/include/core/default/Device.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_DEVICE_H
+#define ANDROID_HARDWARE_AUDIO_DEVICE_H
+
+#include PATH(android/hardware/audio/FILE_VERSION/IDevice.h)
+
+#include "ParametersUtil.h"
 
 #include <memory>
 
@@ -30,41 +35,43 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioConfig;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioHwSync;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioInputFlag;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioOutputFlag;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPatchHandle;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPort;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfig;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioInputFlagBitfield;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::
-    AudioOutputFlagBitfield;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamIn;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOut;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioConfig;
+using ::android::hardware::audio::common::CPP_VERSION::AudioHwSync;
+using ::android::hardware::audio::common::CPP_VERSION::AudioInputFlag;
+using ::android::hardware::audio::common::CPP_VERSION::AudioOutputFlag;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPatchHandle;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPort;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfig;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioInputFlagBitfield;
+using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioOutputFlagBitfield;
+using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
+using ::android::hardware::audio::CPP_VERSION::IDevice;
+using ::android::hardware::audio::CPP_VERSION::IStreamIn;
+using ::android::hardware::audio::CPP_VERSION::IStreamOut;
+using ::android::hardware::audio::CPP_VERSION::ParameterValue;
+using ::android::hardware::audio::CPP_VERSION::Result;
 
-#ifdef AUDIO_HAL_VERSION_4_0
-using ::android::hardware::audio::AUDIO_HAL_VERSION::SourceMetadata;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::SinkMetadata;
+#if MAJOR_VERSION == 4
+using ::android::hardware::audio::CPP_VERSION::SinkMetadata;
+using ::android::hardware::audio::CPP_VERSION::SourceMetadata;
+#elif MAJOR_VERSION >= 5
+using ::android::hardware::audio::common::CPP_VERSION::SinkMetadata;
+using ::android::hardware::audio::common::CPP_VERSION::SourceMetadata;
 #endif
 
 struct Device : public IDevice, public ParametersUtil {
     explicit Device(audio_hw_device_t* device);
 
-    // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice follow.
+    // Methods from ::android::hardware::audio::CPP_VERSION::IDevice follow.
     Return<Result> initCheck() override;
     Return<Result> setMasterVolume(float volume) override;
     Return<void> getMasterVolume(getMasterVolume_cb _hidl_cb) override;
@@ -79,11 +86,11 @@
     Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
                                  const AudioConfig& config, AudioInputFlagBitfield flags,
                                  AudioSource source, openInputStream_cb _hidl_cb);
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device,
                                   const AudioConfig& config, AudioOutputFlagBitfield flags,
                                   openOutputStream_cb _hidl_cb) override;
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
     Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device,
                                   const AudioConfig& config, AudioOutputFlagBitfield flags,
                                   const SourceMetadata& sourceMetadata,
@@ -104,13 +111,13 @@
 
     Return<Result> setScreenState(bool turnedOn) override;
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<AudioHwSync> getHwAvSync() override;
     Return<void> getParameters(const hidl_vec<hidl_string>& keys,
                                getParameters_cb _hidl_cb) override;
     Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
     Return<void> debugDump(const hidl_handle& fd) override;
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
     Return<void> getHwAvSync(getHwAvSync_cb _hidl_cb) override;
     Return<void> getParameters(const hidl_vec<ParameterValue>& context,
                                const hidl_vec<hidl_string>& keys,
@@ -143,7 +150,9 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_DEVICE_H
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.h b/audio/core/all-versions/default/include/core/default/DevicesFactory.h
similarity index 75%
rename from audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.h
rename to audio/core/all-versions/default/include/core/default/DevicesFactory.h
index 1509ad1..3413853 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.h
+++ b/audio/core/all-versions/default/include/core/default/DevicesFactory.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_DEVICESFACTORY_H
+#define ANDROID_HARDWARE_AUDIO_DEVICESFACTORY_H
+
+#include PATH(android/hardware/audio/FILE_VERSION/IDevicesFactory.h)
 
 #include <hardware/audio.h>
 
@@ -24,23 +27,22 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IDevicesFactory;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::CPP_VERSION::IDevice;
+using ::android::hardware::audio::CPP_VERSION::IDevicesFactory;
+using ::android::hardware::audio::CPP_VERSION::Result;
 
 struct DevicesFactory : public IDevicesFactory {
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<void> openDevice(IDevicesFactory::Device device, openDevice_cb _hidl_cb) override;
-#endif
-#ifdef AUDIO_HAL_VERSION_4_0
+#elif MAJOR_VERSION >= 4
     Return<void> openDevice(const hidl_string& device, openDevice_cb _hidl_cb) override;
     Return<void> openPrimaryDevice(openPrimaryDevice_cb _hidl_cb) override;
 #endif
@@ -56,7 +58,9 @@
 extern "C" IDevicesFactory* HIDL_FETCH_IDevicesFactory(const char* name);
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_DEVICESFACTORY_H
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.h b/audio/core/all-versions/default/include/core/default/ParametersUtil.h
similarity index 80%
rename from audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.h
rename to audio/core/all-versions/default/include/core/default/ParametersUtil.h
index 35ff110..ba4ca0c 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.h
+++ b/audio/core/all-versions/default/include/core/default/ParametersUtil.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_PARAMETERS_UTIL_H_
+#define ANDROID_HARDWARE_AUDIO_PARAMETERS_UTIL_H_
+
+#include PATH(android/hardware/audio/FILE_VERSION/types.h)
 
 #include <functional>
 #include <memory>
@@ -25,14 +28,14 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::Result;
 using ::android::hardware::hidl_string;
 using ::android::hardware::hidl_vec;
+using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
+using ::android::hardware::audio::CPP_VERSION::ParameterValue;
+using ::android::hardware::audio::CPP_VERSION::Result;
 
 class ParametersUtil {
    public:
@@ -60,7 +63,9 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_PARAMETERS_UTIL_H_
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.h b/audio/core/all-versions/default/include/core/default/PrimaryDevice.h
similarity index 77%
rename from audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.h
rename to audio/core/all-versions/default/include/core/default/PrimaryDevice.h
index 42996d7..2f7332e 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.h
+++ b/audio/core/all-versions/default/include/core/default/PrimaryDevice.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_PRIMARYDEVICE_H
+#define ANDROID_HARDWARE_AUDIO_PRIMARYDEVICE_H
+
+#include PATH(android/hardware/audio/FILE_VERSION/IPrimaryDevice.h)
+
+#include "Device.h"
 
 #include <hidl/Status.h>
 
@@ -23,33 +28,33 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioConfig;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioInputFlag;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioOutputFlag;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPort;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfig;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IPrimaryDevice;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamIn;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOut;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioConfig;
+using ::android::hardware::audio::common::CPP_VERSION::AudioInputFlag;
+using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
+using ::android::hardware::audio::common::CPP_VERSION::AudioOutputFlag;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPort;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfig;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
+using ::android::hardware::audio::CPP_VERSION::IDevice;
+using ::android::hardware::audio::CPP_VERSION::IPrimaryDevice;
+using ::android::hardware::audio::CPP_VERSION::IStreamIn;
+using ::android::hardware::audio::CPP_VERSION::IStreamOut;
+using ::android::hardware::audio::CPP_VERSION::ParameterValue;
+using ::android::hardware::audio::CPP_VERSION::Result;
 
 struct PrimaryDevice : public IPrimaryDevice {
     explicit PrimaryDevice(audio_hw_device_t* device);
 
-    // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice follow.
+    // Methods from ::android::hardware::audio::CPP_VERSION::IDevice follow.
     Return<Result> initCheck() override;
     Return<Result> setMasterVolume(float volume) override;
     Return<void> getMasterVolume(getMasterVolume_cb _hidl_cb) override;
@@ -62,7 +67,7 @@
 
     Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device,
                                   const AudioConfig& config, AudioOutputFlagBitfield flags,
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
                                   const SourceMetadata& sourceMetadata,
 #endif
                                   openOutputStream_cb _hidl_cb) override;
@@ -70,7 +75,7 @@
     Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
                                  const AudioConfig& config, AudioInputFlagBitfield flags,
                                  AudioSource source, openInputStream_cb _hidl_cb);
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
     Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
                                  const AudioConfig& config, AudioInputFlagBitfield flags,
                                  const SinkMetadata& sinkMetadata,
@@ -87,13 +92,13 @@
 
     Return<Result> setScreenState(bool turnedOn) override;
 
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<AudioHwSync> getHwAvSync() override;
     Return<void> getParameters(const hidl_vec<hidl_string>& keys,
                                getParameters_cb _hidl_cb) override;
     Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
     Return<void> debugDump(const hidl_handle& fd) override;
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
     Return<void> getHwAvSync(getHwAvSync_cb _hidl_cb) override;
     Return<void> getParameters(const hidl_vec<ParameterValue>& context,
                                const hidl_vec<hidl_string>& keys,
@@ -106,7 +111,7 @@
 
     Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
 
-    // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IPrimaryDevice follow.
+    // Methods from ::android::hardware::audio::CPP_VERSION::IPrimaryDevice follow.
     Return<Result> setVoiceVolume(float volume) override;
     Return<Result> setMode(AudioMode mode) override;
     Return<void> getBtScoNrecEnabled(getBtScoNrecEnabled_cb _hidl_cb) override;
@@ -118,7 +123,7 @@
     Return<void> getHacEnabled(getHacEnabled_cb _hidl_cb) override;
     Return<Result> setHacEnabled(bool enabled) override;
 
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
     Return<Result> setBtScoHeadsetDebugName(const hidl_string& name) override;
     Return<void> getBtHfpEnabled(getBtHfpEnabled_cb _hidl_cb) override;
     Return<Result> setBtHfpEnabled(bool enabled) override;
@@ -134,7 +139,9 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_PRIMARYDEVICE_H
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Stream.h b/audio/core/all-versions/default/include/core/default/Stream.h
similarity index 88%
rename from audio/core/all-versions/default/include/core/all-versions/default/Stream.h
rename to audio/core/all-versions/default/include/core/default/Stream.h
index 7cf12dd..34d146e 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/Stream.h
+++ b/audio/core/all-versions/default/include/core/default/Stream.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_STREAM_H
+#define ANDROID_HARDWARE_AUDIO_STREAM_H
+
+#include PATH(android/hardware/audio/FILE_VERSION/IStream.h)
+
+#include "ParametersUtil.h"
 
 #include <vector>
 
@@ -28,22 +33,22 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioChannelBitfield;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IStream;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioFormat;
+using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield;
+using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
+using ::android::hardware::audio::CPP_VERSION::IStream;
+using ::android::hardware::audio::CPP_VERSION::ParameterValue;
+using ::android::hardware::audio::CPP_VERSION::Result;
 
 struct Stream : public IStream, public ParametersUtil {
     explicit Stream(audio_stream_t* stream);
@@ -55,12 +60,12 @@
      */
     static constexpr uint32_t MAX_BUFFER_SIZE = 2 << 30 /* == 1GiB */;
 
-    // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStream follow.
+    // Methods from ::android::hardware::audio::CPP_VERSION::IStream follow.
     Return<uint64_t> getFrameSize() override;
     Return<uint64_t> getFrameCount() override;
     Return<uint64_t> getBufferSize() override;
     Return<uint32_t> getSampleRate() override;
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override;
     Return<void> getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) override;
 #endif
@@ -76,14 +81,14 @@
     Return<Result> addEffect(uint64_t effectId) override;
     Return<Result> removeEffect(uint64_t effectId) override;
     Return<Result> standby() override;
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<AudioDevice> getDevice() override;
     Return<Result> setDevice(const DeviceAddress& address) override;
     Return<void> getParameters(const hidl_vec<hidl_string>& keys,
                                getParameters_cb _hidl_cb) override;
     Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
     Return<Result> setConnectedState(const DeviceAddress& address, bool connected) override;
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
     Return<void> getDevices(getDevices_cb _hidl_cb) override;
     Return<Result> setDevices(const hidl_vec<DeviceAddress>& devices) override;
     Return<void> getParameters(const hidl_vec<ParameterValue>& context,
@@ -100,7 +105,7 @@
     Return<Result> close() override;
 
     Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<void> debugDump(const hidl_handle& fd) override;
 #endif
 
@@ -171,7 +176,7 @@
             halInfo.buffer_size_frames = abs(halInfo.buffer_size_frames);
             info.sharedMemory =  // hidl_memory size must always be positive
                 hidl_memory("audio_buffer", hidlHandle, frameSize * halInfo.buffer_size_frames);
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
             if (applicationShareable) {
                 halInfo.buffer_size_frames *= -1;
             }
@@ -210,7 +215,9 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_STREAM_H
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.h b/audio/core/all-versions/default/include/core/default/StreamIn.h
similarity index 81%
rename from audio/core/all-versions/default/include/core/all-versions/default/StreamIn.h
rename to audio/core/all-versions/default/include/core/default/StreamIn.h
index f226e63..057c6f3 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.h
+++ b/audio/core/all-versions/default/include/core/default/StreamIn.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,13 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_STREAMIN_H
+#define ANDROID_HARDWARE_AUDIO_STREAMIN_H
+
+#include PATH(android/hardware/audio/FILE_VERSION/IStreamIn.h)
+
+#include "Device.h"
+#include "Stream.h"
 
 #include <atomic>
 #include <memory>
@@ -28,23 +34,23 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IStream;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamIn;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioFormat;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
+using ::android::hardware::audio::CPP_VERSION::IStream;
+using ::android::hardware::audio::CPP_VERSION::IStreamIn;
+using ::android::hardware::audio::CPP_VERSION::ParameterValue;
+using ::android::hardware::audio::CPP_VERSION::Result;
 
 struct StreamIn : public IStreamIn {
     typedef MessageQueue<ReadParameters, kSynchronizedReadWrite> CommandMQ;
@@ -53,12 +59,12 @@
 
     StreamIn(const sp<Device>& device, audio_stream_in_t* stream);
 
-    // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStream follow.
+    // Methods from ::android::hardware::audio::CPP_VERSION::IStream follow.
     Return<uint64_t> getFrameSize() override;
     Return<uint64_t> getFrameCount() override;
     Return<uint64_t> getBufferSize() override;
     Return<uint32_t> getSampleRate() override;
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override;
     Return<void> getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) override;
 #endif
@@ -74,14 +80,14 @@
     Return<Result> addEffect(uint64_t effectId) override;
     Return<Result> removeEffect(uint64_t effectId) override;
     Return<Result> standby() override;
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<AudioDevice> getDevice() override;
     Return<Result> setDevice(const DeviceAddress& address) override;
     Return<void> getParameters(const hidl_vec<hidl_string>& keys,
                                getParameters_cb _hidl_cb) override;
     Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
     Return<Result> setConnectedState(const DeviceAddress& address, bool connected) override;
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
     Return<void> getDevices(getDevices_cb _hidl_cb) override;
     Return<Result> setDevices(const hidl_vec<DeviceAddress>& devices) override;
     Return<void> getParameters(const hidl_vec<ParameterValue>& context,
@@ -94,11 +100,11 @@
     Return<Result> close() override;
 
     Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<void> debugDump(const hidl_handle& fd) override;
 #endif
 
-    // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamIn follow.
+    // Methods from ::android::hardware::audio::CPP_VERSION::IStreamIn follow.
     Return<void> getAudioSource(getAudioSource_cb _hidl_cb) override;
     Return<Result> setGain(float gain) override;
     Return<void> prepareForReading(uint32_t frameSize, uint32_t framesCount,
@@ -109,7 +115,7 @@
     Return<Result> stop() override;
     Return<void> createMmapBuffer(int32_t minSizeFrames, createMmapBuffer_cb _hidl_cb) override;
     Return<void> getMmapPosition(getMmapPosition_cb _hidl_cb) override;
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
     Return<void> updateSinkMetadata(const SinkMetadata& sinkMetadata) override;
     Return<void> getActiveMicrophones(getActiveMicrophones_cb _hidl_cb) override;
 #endif
@@ -134,7 +140,9 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_STREAMIN_H
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.h b/audio/core/all-versions/default/include/core/default/StreamOut.h
similarity index 81%
rename from audio/core/all-versions/default/include/core/all-versions/default/StreamOut.h
rename to audio/core/all-versions/default/include/core/default/StreamOut.h
index 134d7b9..bcae97f 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.h
+++ b/audio/core/all-versions/default/include/core/default/StreamOut.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,13 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_STREAMOUT_H
+#define ANDROID_HARDWARE_AUDIO_STREAMOUT_H
+
+#include PATH(android/hardware/audio/FILE_VERSION/IStreamOut.h)
+
+#include "Device.h"
+#include "Stream.h"
 
 #include <atomic>
 #include <memory>
@@ -28,25 +34,25 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::AudioDrain;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IStream;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOut;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOutCallback;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::Result;
-using ::android::hardware::audio::AUDIO_HAL_VERSION::TimeSpec;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioFormat;
+using ::android::hardware::audio::CPP_VERSION::AudioDrain;
+using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
+using ::android::hardware::audio::CPP_VERSION::IStream;
+using ::android::hardware::audio::CPP_VERSION::IStreamOut;
+using ::android::hardware::audio::CPP_VERSION::IStreamOutCallback;
+using ::android::hardware::audio::CPP_VERSION::ParameterValue;
+using ::android::hardware::audio::CPP_VERSION::Result;
+using ::android::hardware::audio::CPP_VERSION::TimeSpec;
 
 struct StreamOut : public IStreamOut {
     typedef MessageQueue<WriteCommand, kSynchronizedReadWrite> CommandMQ;
@@ -55,12 +61,12 @@
 
     StreamOut(const sp<Device>& device, audio_stream_out_t* stream);
 
-    // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStream follow.
+    // Methods from ::android::hardware::audio::CPP_VERSION::IStream follow.
     Return<uint64_t> getFrameSize() override;
     Return<uint64_t> getFrameCount() override;
     Return<uint64_t> getBufferSize() override;
     Return<uint32_t> getSampleRate() override;
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override;
     Return<void> getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) override;
 #endif
@@ -76,14 +82,14 @@
     Return<Result> addEffect(uint64_t effectId) override;
     Return<Result> removeEffect(uint64_t effectId) override;
     Return<Result> standby() override;
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<AudioDevice> getDevice() override;
     Return<Result> setDevice(const DeviceAddress& address) override;
     Return<void> getParameters(const hidl_vec<hidl_string>& keys,
                                getParameters_cb _hidl_cb) override;
     Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
     Return<Result> setConnectedState(const DeviceAddress& address, bool connected) override;
-#elif defined(AUDIO_HAL_VERSION_4_0)
+#elif MAJOR_VERSION >= 4
     Return<void> getDevices(getDevices_cb _hidl_cb) override;
     Return<Result> setDevices(const hidl_vec<DeviceAddress>& devices) override;
     Return<void> getParameters(const hidl_vec<ParameterValue>& context,
@@ -96,11 +102,11 @@
     Return<Result> close() override;
 
     Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
-#ifdef AUDIO_HAL_VERSION_2_0
+#if MAJOR_VERSION == 2
     Return<void> debugDump(const hidl_handle& fd) override;
 #endif
 
-    // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOut follow.
+    // Methods from ::android::hardware::audio::CPP_VERSION::IStreamOut follow.
     Return<uint32_t> getLatency() override;
     Return<Result> setVolume(float left, float right) override;
     Return<void> prepareForWriting(uint32_t frameSize, uint32_t framesCount,
@@ -120,7 +126,7 @@
     Return<Result> stop() override;
     Return<void> createMmapBuffer(int32_t minSizeFrames, createMmapBuffer_cb _hidl_cb) override;
     Return<void> getMmapPosition(getMmapPosition_cb _hidl_cb) override;
-#ifdef AUDIO_HAL_VERSION_4_0
+#if MAJOR_VERSION >= 4
     Return<void> updateSourceMetadata(const SourceMetadata& sourceMetadata) override;
     Return<Result> selectPresentation(int32_t presentationId, int32_t programId) override;
 #endif
@@ -148,7 +154,9 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_STREAMOUT_H
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Util.h b/audio/core/all-versions/default/include/core/default/Util.h
similarity index 85%
rename from audio/core/all-versions/default/include/core/all-versions/default/Util.h
rename to audio/core/all-versions/default/include/core/default/Util.h
index 350fd86..2b8c3fd 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/Util.h
+++ b/audio/core/all-versions/default/include/core/default/Util.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_UTIL_H
+#define ANDROID_HARDWARE_AUDIO_UTIL_H
+
+#include PATH(android/hardware/audio/FILE_VERSION/types.h)
 
 #include <algorithm>
 #include <vector>
@@ -24,10 +27,10 @@
 namespace android {
 namespace hardware {
 namespace audio {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::AUDIO_HAL_VERSION::Result;
+using ::android::hardware::audio::CPP_VERSION::Result;
 
 /** @return true if gain is between 0 and 1 included. */
 constexpr bool isGainNormalized(float gain) {
@@ -68,7 +71,9 @@
 
 }  // namespace util
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_UTIL_H
diff --git a/audio/core/2.0/vts/OWNERS b/audio/core/all-versions/vts/OWNERS
similarity index 98%
rename from audio/core/2.0/vts/OWNERS
rename to audio/core/all-versions/vts/OWNERS
index 8711a9f..0ea4666 100644
--- a/audio/core/2.0/vts/OWNERS
+++ b/audio/core/all-versions/vts/OWNERS
@@ -2,4 +2,4 @@
 krocard@google.com
 mnaganov@google.com
 yim@google.com
-zhuoyao@google.com
\ No newline at end of file
+zhuoyao@google.com
diff --git a/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalTest.cpp
new file mode 100644
index 0000000..7906bf1
--- /dev/null
+++ b/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalTest.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2018 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 "AudioPrimaryHidlHalTest.h"
+
+static void testGetDevice(IStream* stream, AudioDevice expectedDevice) {
+    // Unfortunately the interface does not allow the implementation to return
+    // NOT_SUPPORTED
+    // Thus allow NONE as signaling that the call is not supported.
+    auto ret = stream->getDevice();
+    ASSERT_IS_OK(ret);
+    AudioDevice device = ret;
+    ASSERT_TRUE(device == expectedDevice || device == AudioDevice::NONE)
+        << "Expected: " << ::testing::PrintToString(expectedDevice)
+        << "\n  Actual: " << ::testing::PrintToString(device);
+}
+
+TEST_IO_STREAM(GetDevice, "Check that the stream device == the one it was opened with",
+               areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
+                                          : testGetDevice(stream.get(), address.device))
+
+static void testSetDevice(IStream* stream, const DeviceAddress& address) {
+    DeviceAddress otherAddress = address;
+    otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER
+                                                                      : AudioDevice::IN_BUILTIN_MIC;
+    EXPECT_OK(stream->setDevice(otherAddress));
+
+    ASSERT_OK(stream->setDevice(address));  // Go back to the original value
+}
+
+TEST_IO_STREAM(SetDevice, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
+               areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
+                                          : testSetDevice(stream.get(), address))
+
+static void testConnectedState(IStream* stream) {
+    DeviceAddress address = {};
+    using AD = AudioDevice;
+    for (auto device : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) {
+        address.device = device;
+
+        ASSERT_OK(stream->setConnectedState(address, true));
+        ASSERT_OK(stream->setConnectedState(address, false));
+    }
+}
+TEST_IO_STREAM(SetConnectedState,
+               "Check that the stream can be notified of device connection and "
+               "deconnection",
+               testConnectedState(stream.get()))
+
+TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", ASSERT_IS_OK(device->getHwAvSync()));
+
+TEST_F(AudioPrimaryHidlTest, setMode) {
+    doc::test("Make sure setMode always succeeds if mode is valid and fails otherwise");
+    // Test Invalid values
+    for (AudioMode mode : {AudioMode::INVALID, AudioMode::CURRENT, AudioMode::CNT}) {
+        SCOPED_TRACE("mode=" + toString(mode));
+        ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(mode));
+    }
+    // Test valid values
+    for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE,
+                           AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) {
+        SCOPED_TRACE("mode=" + toString(mode));
+        ASSERT_OK(device->setMode(mode));
+    }
+}
diff --git a/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalUtils.h b/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalUtils.h
new file mode 100644
index 0000000..1cffd41
--- /dev/null
+++ b/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalUtils.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2018 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 PATH(android/hardware/audio/FILE_VERSION/IStream.h)
+#include PATH(android/hardware/audio/FILE_VERSION/types.h)
+#include PATH(android/hardware/audio/common/FILE_VERSION/types.h)
+#include <hidl/HidlSupport.h>
+
+using ::android::hardware::hidl_handle;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
+using ::android::hardware::audio::common::CPP_VERSION::AudioFormat;
+using ::android::hardware::audio::CPP_VERSION::IStream;
+using ::android::hardware::audio::CPP_VERSION::ParameterValue;
+using ::android::hardware::audio::CPP_VERSION::Result;
+
+using namespace ::android::hardware::audio::common::test::utility;
+
+struct Parameters {
+    template <class T, class ReturnIn>
+    static auto get(T t, hidl_vec<hidl_string> keys, ReturnIn returnIn) {
+        return t->getParameters(keys, returnIn);
+    }
+    template <class T>
+    static auto set(T t, hidl_vec<ParameterValue> values) {
+        return t->setParameters(values);
+    }
+};
+
+// The default hal should probably return a NOT_SUPPORTED if the hal
+// does not expose
+// capability retrieval. For now it returns an empty list if not
+// implemented
+struct GetSupported {
+    template <class Vec>
+    static Result convertToResult(const Vec& vec) {
+        return vec.size() == 0 ? Result::NOT_SUPPORTED : Result::OK;
+    }
+
+    static Result sampleRates(IStream* stream, hidl_vec<uint32_t>& rates) {
+        EXPECT_OK(stream->getSupportedSampleRates(returnIn(rates)));
+        return convertToResult(rates);
+    }
+
+    static Result channelMasks(IStream* stream, hidl_vec<AudioChannelMask>& channels) {
+        EXPECT_OK(stream->getSupportedChannelMasks(returnIn(channels)));
+        return convertToResult(channels);
+    }
+
+    static Result formats(IStream* stream, hidl_vec<AudioFormat>& capabilities) {
+        EXPECT_OK(stream->getSupportedFormats(returnIn(capabilities)));
+        // TODO: this should be an optional function
+        return Result::OK;
+    }
+};
+
+template <class T>
+auto dump(T t, hidl_handle handle) {
+    return t->debugDump(handle);
+}
diff --git a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp
new file mode 100644
index 0000000..e7c1e58
--- /dev/null
+++ b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp
@@ -0,0 +1,309 @@
+/*
+ * Copyright (C) 2018 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 "AudioPrimaryHidlHalTest.h"
+
+static void waitForDeviceDestruction() {
+    // FIXME: there is no way to know when the remote IDevice is being destroyed
+    //        Binder does not support testing if an object is alive, thus
+    //        wait for 100ms to let the binder destruction propagates and
+    //        the remote device has the time to be destroyed.
+    //        flushCommand makes sure all local command are sent, thus should reduce
+    //        the latency between local and remote destruction.
+    IPCThreadState::self()->flushCommands();
+    usleep(100);
+}
+
+TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {
+    doc::test("Calling openDevice(\"primary\") should return the primary device.");
+    {
+        Result result;
+        sp<IDevice> baseDevice;
+        ASSERT_OK(devicesFactory->openDevice("primary", returnIn(result, baseDevice)));
+        ASSERT_OK(result);
+        ASSERT_TRUE(baseDevice != nullptr);
+
+        Return<sp<IPrimaryDevice>> primaryDevice = IPrimaryDevice::castFrom(baseDevice);
+        ASSERT_TRUE(primaryDevice.isOk());
+        ASSERT_TRUE(sp<IPrimaryDevice>(primaryDevice) != nullptr);
+    }  // Destroy local IDevice proxy
+    waitForDeviceDestruction();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+/////////////////////////// get(Active)Microphones ///////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) {
+    doc::test("Make sure getMicrophones always succeeds");
+    hidl_vec<MicrophoneInfo> microphones;
+    ASSERT_OK(device->getMicrophones(returnIn(res, microphones)));
+    ASSERT_OK(res);
+    if (microphones.size() > 0) {
+        // When there is microphone on the phone, try to open an input stream
+        // and query for the active microphones.
+        doc::test(
+            "Make sure getMicrophones always succeeds"
+            "and getActiveMicrophones always succeeds when recording from these microphones.");
+        AudioIoHandle ioHandle = (AudioIoHandle)AudioHandleConsts::AUDIO_IO_HANDLE_NONE;
+        AudioConfig config{};
+        config.channelMask = mkEnumBitfield(AudioChannelMask::IN_MONO);
+        config.sampleRateHz = 8000;
+        config.format = AudioFormat::PCM_16_BIT;
+        auto flags = hidl_bitfield<AudioInputFlag>(AudioInputFlag::NONE);
+        const SinkMetadata initMetadata = {{{AudioSource::MIC, 1 /* gain */}}};
+        EventFlag* efGroup;
+        for (auto microphone : microphones) {
+            if (microphone.deviceAddress.device != AudioDevice::IN_BUILTIN_MIC) {
+                continue;
+            }
+            sp<IStreamIn> stream;
+            AudioConfig suggestedConfig{};
+            ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress, config, flags,
+                                              initMetadata,
+                                              returnIn(res, stream, suggestedConfig)));
+            if (res != Result::OK) {
+                ASSERT_TRUE(stream == nullptr);
+                AudioConfig suggestedConfigRetry{};
+                ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress,
+                                                  suggestedConfig, flags, initMetadata,
+                                                  returnIn(res, stream, suggestedConfigRetry)));
+            }
+            ASSERT_OK(res);
+            hidl_vec<MicrophoneInfo> activeMicrophones;
+            Result readRes;
+            typedef MessageQueue<ReadParameters, kSynchronizedReadWrite> CommandMQ;
+            typedef MessageQueue<uint8_t, kSynchronizedReadWrite> DataMQ;
+            std::unique_ptr<CommandMQ> commandMQ;
+            std::unique_ptr<DataMQ> dataMQ;
+            size_t frameSize = stream->getFrameSize();
+            size_t frameCount = stream->getBufferSize() / frameSize;
+            ASSERT_OK(stream->prepareForReading(
+                frameSize, frameCount, [&](auto r, auto& c, auto& d, auto&, auto&) {
+                    readRes = r;
+                    if (readRes == Result::OK) {
+                        commandMQ.reset(new CommandMQ(c));
+                        dataMQ.reset(new DataMQ(d));
+                        if (dataMQ->isValid() && dataMQ->getEventFlagWord()) {
+                            EventFlag::createEventFlag(dataMQ->getEventFlagWord(), &efGroup);
+                        }
+                    }
+                }));
+            ASSERT_OK(readRes);
+            ReadParameters params;
+            params.command = IStreamIn::ReadCommand::READ;
+            ASSERT_TRUE(commandMQ != nullptr);
+            ASSERT_TRUE(commandMQ->isValid());
+            ASSERT_TRUE(commandMQ->write(&params));
+            efGroup->wake(static_cast<uint32_t>(MessageQueueFlagBits::NOT_FULL));
+            uint32_t efState = 0;
+            efGroup->wait(static_cast<uint32_t>(MessageQueueFlagBits::NOT_EMPTY), &efState);
+            if (efState & static_cast<uint32_t>(MessageQueueFlagBits::NOT_EMPTY)) {
+                ASSERT_OK(stream->getActiveMicrophones(returnIn(res, activeMicrophones)));
+                ASSERT_OK(res);
+                ASSERT_NE(0U, activeMicrophones.size());
+            }
+            stream->close();
+            if (efGroup) {
+                EventFlag::deleteEventFlag(&efGroup);
+            }
+        }
+    }
+}
+
+TEST_F(AudioPrimaryHidlTest, SetConnectedState) {
+    doc::test("Check that the HAL can be notified of device connection and deconnection");
+    using AD = AudioDevice;
+    for (auto deviceType : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) {
+        SCOPED_TRACE("device=" + ::testing::PrintToString(deviceType));
+        for (bool state : {true, false}) {
+            SCOPED_TRACE("state=" + ::testing::PrintToString(state));
+            DeviceAddress address = {};
+            address.device = deviceType;
+            auto ret = device->setConnectedState(address, state);
+            ASSERT_TRUE(ret.isOk());
+            if (ret == Result::NOT_SUPPORTED) {
+                doc::partialTest("setConnectedState is not supported");
+                break;  // other deviceType might be supported
+            }
+            ASSERT_OK(ret);
+        }
+    }
+
+    // Because there is no way of knowing if the devices were connected before
+    // calling setConnectedState, there is no way to restore the HAL to its
+    // initial state. To workaround this, destroy the HAL at the end of this test.
+    device.clear();
+    waitForDeviceDestruction();
+}
+
+static void testGetDevices(IStream* stream, AudioDevice expectedDevice) {
+    hidl_vec<DeviceAddress> devices;
+    Result res;
+    ASSERT_OK(stream->getDevices(returnIn(res, devices)));
+    if (res == Result::NOT_SUPPORTED) {
+        return doc::partialTest("GetDevices is not supported");
+    }
+    // The stream was constructed with one device, thus getDevices must only return one
+    ASSERT_EQ(1U, devices.size());
+    AudioDevice device = devices[0].device;
+    ASSERT_TRUE(device == expectedDevice)
+        << "Expected: " << ::testing::PrintToString(expectedDevice)
+        << "\n  Actual: " << ::testing::PrintToString(device);
+}
+
+TEST_IO_STREAM(GetDevices, "Check that the stream device == the one it was opened with",
+               areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
+                                          : testGetDevices(stream.get(), address.device))
+
+static void testSetDevices(IStream* stream, const DeviceAddress& address) {
+    DeviceAddress otherAddress = address;
+    otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER
+                                                                      : AudioDevice::IN_BUILTIN_MIC;
+    EXPECT_OK(stream->setDevices({otherAddress}));
+
+    ASSERT_OK(stream->setDevices({address}));  // Go back to the original value
+}
+
+TEST_IO_STREAM(SetDevices, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
+               areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
+                                          : testSetDevices(stream.get(), address))
+
+static void checkGetHwAVSync(IDevice* device) {
+    Result res;
+    AudioHwSync sync;
+    ASSERT_OK(device->getHwAvSync(returnIn(res, sync)));
+    if (res == Result::NOT_SUPPORTED) {
+        return doc::partialTest("getHwAvSync is not supported");
+    }
+    ASSERT_OK(res);
+}
+TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", checkGetHwAVSync(device.get()));
+
+TEST_P(InputStreamTest, updateSinkMetadata) {
+    doc::test("The HAL should not crash on metadata change");
+
+    hidl_enum_range<AudioSource> range;
+    // Test all possible track configuration
+    for (AudioSource source : range) {
+        for (float volume : {0.0, 0.5, 1.0}) {
+            const SinkMetadata metadata = {{{source, volume}}};
+            ASSERT_OK(stream->updateSinkMetadata(metadata))
+                << "source=" << toString(source) << ", volume=" << volume;
+        }
+    }
+
+    // Do not test concurrent capture as this is not officially supported
+
+    // Set no metadata as if all stream track had stopped
+    ASSERT_OK(stream->updateSinkMetadata({}));
+
+    // Restore initial
+    ASSERT_OK(stream->updateSinkMetadata(initMetadata));
+}
+
+TEST_P(OutputStreamTest, SelectPresentation) {
+    doc::test("Verify that presentation selection does not crash");
+    ASSERT_RESULT(okOrNotSupported, stream->selectPresentation(0, 0));
+}
+
+TEST_P(OutputStreamTest, updateSourceMetadata) {
+    doc::test("The HAL should not crash on metadata change");
+
+    hidl_enum_range<AudioUsage> usageRange;
+    hidl_enum_range<AudioContentType> contentRange;
+    // Test all possible track configuration
+    for (auto usage : usageRange) {
+        for (auto content : contentRange) {
+            for (float volume : {0.0, 0.5, 1.0}) {
+                const SourceMetadata metadata = {{{usage, content, volume}}};
+                ASSERT_OK(stream->updateSourceMetadata(metadata))
+                    << "usage=" << toString(usage) << ", content=" << toString(content)
+                    << ", volume=" << volume;
+            }
+        }
+    }
+
+    // Set many track of different configuration
+    ASSERT_OK(stream->updateSourceMetadata(
+        {{{AudioUsage::MEDIA, AudioContentType::MUSIC, 0.1},
+          {AudioUsage::VOICE_COMMUNICATION, AudioContentType::SPEECH, 1.0},
+          {AudioUsage::ALARM, AudioContentType::SONIFICATION, 0.0},
+          {AudioUsage::ASSISTANT, AudioContentType::UNKNOWN, 0.3}}}));
+
+    // Set no metadata as if all stream track had stopped
+    ASSERT_OK(stream->updateSourceMetadata({}));
+
+    // Restore initial
+    ASSERT_OK(stream->updateSourceMetadata(initMetadata));
+}
+
+TEST_F(AudioPrimaryHidlTest, setMode) {
+    doc::test("Make sure setMode always succeeds if mode is valid and fails otherwise");
+    // Test Invalid values
+    for (int mode : {-2, -1, int(AudioMode::IN_COMMUNICATION) + 1}) {
+        ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(AudioMode(mode)))
+            << "mode=" << mode;
+    }
+    // Test valid values
+    for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE,
+                           AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) {
+        ASSERT_OK(device->setMode(mode)) << "mode=" << toString(mode);
+    }
+}
+
+TEST_F(AudioPrimaryHidlTest, setBtHfpSampleRate) {
+    doc::test(
+        "Make sure setBtHfpSampleRate either succeeds or "
+        "indicates that it is not supported at all, or that the provided value is invalid");
+    for (auto samplingRate : {8000, 16000, 22050, 24000}) {
+        ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, device->setBtHfpSampleRate(samplingRate));
+    }
+}
+
+TEST_F(AudioPrimaryHidlTest, setBtHfpVolume) {
+    doc::test(
+        "Make sure setBtHfpVolume is either not supported or "
+        "only succeed if volume is in [0,1]");
+    auto ret = device->setBtHfpVolume(0.0);
+    ASSERT_TRUE(ret.isOk());
+    if (ret == Result::NOT_SUPPORTED) {
+        doc::partialTest("setBtHfpVolume is not supported");
+        return;
+    }
+    testUnitaryGain([](float volume) { return device->setBtHfpVolume(volume); });
+}
+
+TEST_F(AudioPrimaryHidlTest, setBtScoHeadsetDebugName) {
+    doc::test(
+        "Make sure setBtScoHeadsetDebugName either succeeds or "
+        "indicates that it is not supported");
+    ASSERT_RESULT(okOrNotSupported, device->setBtScoHeadsetDebugName("test"));
+}
+
+TEST_F(AudioPrimaryHidlTest, updateRotation) {
+    doc::test("Check that the hal can receive the current rotation");
+    for (Rotation rotation : {Rotation::DEG_0, Rotation::DEG_90, Rotation::DEG_180,
+                              Rotation::DEG_270, Rotation::DEG_0}) {
+        ASSERT_RESULT(okOrNotSupported, device->updateRotation(rotation));
+    }
+}
+
+TEST_F(BoolAccessorPrimaryHidlTest, setGetBtHfpEnabled) {
+    doc::test("Query and set the BT HFP state");
+    testAccessors<OPTIONAL>("BtHfpEnabled", Initial{false, OPTIONAL}, {true},
+                            &IPrimaryDevice::setBtHfpEnabled, &IPrimaryDevice::getBtHfpEnabled);
+}
diff --git a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalUtils.h b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalUtils.h
new file mode 100644
index 0000000..8415053
--- /dev/null
+++ b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalUtils.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2018 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 PATH(android/hardware/audio/FILE_VERSION/IStream.h)
+#include PATH(android/hardware/audio/FILE_VERSION/types.h)
+#include PATH(android/hardware/audio/common/FILE_VERSION/types.h)
+#include <hidl/HidlSupport.h>
+
+using ::android::hardware::hidl_bitfield;
+using ::android::hardware::hidl_handle;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
+using ::android::hardware::audio::common::CPP_VERSION::AudioFormat;
+using ::android::hardware::audio::CPP_VERSION::IStream;
+using ::android::hardware::audio::CPP_VERSION::ParameterValue;
+using ::android::hardware::audio::CPP_VERSION::Result;
+
+using namespace ::android::hardware::audio::common::test::utility;
+
+using Rotation = ::android::hardware::audio::CPP_VERSION::IPrimaryDevice::Rotation;
+using ::android::hardware::audio::common::CPP_VERSION::AudioContentType;
+using ::android::hardware::audio::common::CPP_VERSION::AudioUsage;
+using ::android::hardware::audio::CPP_VERSION::MicrophoneInfo;
+#if MAJOR_VERSION < 5
+using ::android::hardware::audio::CPP_VERSION::SinkMetadata;
+using ::android::hardware::audio::CPP_VERSION::SourceMetadata;
+#else
+using ::android::hardware::audio::common::CPP_VERSION::SinkMetadata;
+using ::android::hardware::audio::common::CPP_VERSION::SourceMetadata;
+#endif
+
+struct Parameters {
+    template <class T, class ReturnIn>
+    static auto get(T t, hidl_vec<hidl_string> keys, ReturnIn returnIn) {
+        hidl_vec<ParameterValue> context;
+        return t->getParameters(context, keys, returnIn);
+    }
+    template <class T>
+    static auto set(T t, hidl_vec<ParameterValue> values) {
+        hidl_vec<ParameterValue> context;
+        return t->setParameters(context, values);
+    }
+};
+
+struct GetSupported {
+    static auto getFormat(IStream* stream) {
+        auto ret = stream->getFormat();
+        EXPECT_TRUE(ret.isOk());
+        return ret.withDefault({});
+    }
+    static Result sampleRates(IStream* stream, hidl_vec<uint32_t>& rates) {
+        Result res;
+        EXPECT_OK(stream->getSupportedSampleRates(getFormat(stream), returnIn(res, rates)));
+        return res;
+    }
+
+    static Result channelMasks(IStream* stream,
+                               hidl_vec<hidl_bitfield<AudioChannelMask>>& channels) {
+        Result res;
+        EXPECT_OK(stream->getSupportedChannelMasks(getFormat(stream), returnIn(res, channels)));
+        return res;
+    }
+
+    static Result formats(IStream* stream, hidl_vec<AudioFormat>& capabilities) {
+        EXPECT_OK(stream->getSupportedFormats(returnIn(capabilities)));
+        // TODO: this should be an optional function
+        return Result::OK;
+    }
+};
+
+template <class T>
+auto dump(T t, hidl_handle handle) {
+    return t->debug(handle, {/* options */});
+}
diff --git a/audio/core/all-versions/vts/functional/Android.bp b/audio/core/all-versions/vts/functional/Android.bp
new file mode 100644
index 0000000..b04adf7
--- /dev/null
+++ b/audio/core/all-versions/vts/functional/Android.bp
@@ -0,0 +1,87 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_defaults {
+    name: "VtsHalAudioTargetTest_defaults",
+    defaults: ["VtsHalTargetTestDefaults"],
+    static_libs: [
+        "android.hardware.audio.common.test.utility",
+        "libaudiopolicycomponents",
+        "libicuuc",
+        "libicuuc_stubdata",
+        "libmedia_helper",
+        "libxml2",
+    ],
+    shared_libs: [
+        "libfmq",
+    ],
+    header_libs: [
+        "android.hardware.audio.common.util@all-versions",
+    ],
+    test_suites: ["general-tests"],
+}
+
+cc_test {
+    name: "VtsHalAudioV2_0TargetTest",
+    defaults: ["VtsHalAudioTargetTest_defaults"],
+    srcs: [
+        "2.0/AudioPrimaryHidlHalTest.cpp",
+    ],
+    static_libs: [
+        "android.hardware.audio@2.0",
+        "android.hardware.audio.common@2.0",
+    ],
+    cflags: [
+        "-DMAJOR_VERSION=2",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
+
+cc_test {
+    name: "VtsHalAudioV4_0TargetTest",
+    defaults: ["VtsHalAudioTargetTest_defaults"],
+    srcs: [
+        "4.0/AudioPrimaryHidlHalTest.cpp",
+    ],
+    static_libs: [
+        "android.hardware.audio@4.0",
+        "android.hardware.audio.common@4.0",
+    ],
+    cflags: [
+        "-DMAJOR_VERSION=4",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
+
+cc_test {
+    name: "VtsHalAudioV5_0TargetTest",
+    defaults: ["VtsHalAudioTargetTest_defaults"],
+    srcs: [
+        // for now the tests are the same as V4
+        "4.0/AudioPrimaryHidlHalTest.cpp",
+    ],
+    static_libs: [
+        "android.hardware.audio@5.0",
+        "android.hardware.audio.common@5.0",
+    ],
+    cflags: [
+        "-DMAJOR_VERSION=5",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
diff --git a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h
similarity index 72%
rename from audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
rename to audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h
index f1e0b21..eeffb60 100644
--- a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "VtsHalAudioV4_0TargetTest"
+#define LOG_TAG "VtsHalAudioVTargetTest"
 
 #include <algorithm>
 #include <cmath>
@@ -35,11 +35,13 @@
 
 #include <android-base/logging.h>
 
-#include <android/hardware/audio/4.0/IDevice.h>
-#include <android/hardware/audio/4.0/IDevicesFactory.h>
-#include <android/hardware/audio/4.0/IPrimaryDevice.h>
-#include <android/hardware/audio/4.0/types.h>
-#include <android/hardware/audio/common/4.0/types.h>
+#include PATH(android/hardware/audio/FILE_VERSION/IDevice.h)
+#include PATH(android/hardware/audio/FILE_VERSION/IDevicesFactory.h)
+#include PATH(android/hardware/audio/FILE_VERSION/IPrimaryDevice.h)
+#include PATH(android/hardware/audio/FILE_VERSION/types.h)
+#include PATH(android/hardware/audio/common/FILE_VERSION/types.h)
+
+#include <Serializer.h>
 #include <fmq/EventFlag.h>
 #include <fmq/MessageQueue.h>
 
@@ -48,17 +50,29 @@
 #include "utility/AssertOk.h"
 #include "utility/Documentation.h"
 #include "utility/EnvironmentTearDown.h"
-#define AUDIO_HAL_VERSION V4_0
 #include "utility/PrettyPrintAudioTypes.h"
 #include "utility/ReturnIn.h"
+#include "utility/ValidateXml.h"
+
+/** Provide version specific functions that are used in the generic tests */
+#if MAJOR_VERSION == 2
+#include "2.0/AudioPrimaryHidlHalUtils.h"
+#elif MAJOR_VERSION >= 4
+#include "4.0/AudioPrimaryHidlHalUtils.h"
+#endif
 
 using std::initializer_list;
+using std::list;
 using std::string;
 using std::to_string;
 using std::vector;
-using std::list;
 
+using ::android::AudioPolicyConfig;
+using ::android::HwModule;
+using ::android::NO_INIT;
+using ::android::OK;
 using ::android::sp;
+using ::android::status_t;
 using ::android::hardware::EventFlag;
 using ::android::hardware::hidl_bitfield;
 using ::android::hardware::hidl_enum_range;
@@ -70,44 +84,38 @@
 using ::android::hardware::MessageQueue;
 using ::android::hardware::MQDescriptorSync;
 using ::android::hardware::Return;
-using ::android::hardware::audio::V4_0::AudioDrain;
-using ::android::hardware::audio::V4_0::DeviceAddress;
-using ::android::hardware::audio::V4_0::IDevice;
-using ::android::hardware::audio::V4_0::IPrimaryDevice;
-using Rotation = ::android::hardware::audio::V4_0::IPrimaryDevice::Rotation;
-using TtyMode = ::android::hardware::audio::V4_0::IPrimaryDevice::TtyMode;
-using ::android::hardware::audio::V4_0::IDevicesFactory;
-using ::android::hardware::audio::V4_0::IStream;
-using ::android::hardware::audio::V4_0::IStreamIn;
-using ::android::hardware::audio::V4_0::MessageQueueFlagBits;
-using ::android::hardware::audio::V4_0::TimeSpec;
-using ReadParameters = ::android::hardware::audio::V4_0::IStreamIn::ReadParameters;
-using ReadStatus = ::android::hardware::audio::V4_0::IStreamIn::ReadStatus;
-using ::android::hardware::audio::V4_0::IStreamOut;
-using ::android::hardware::audio::V4_0::IStreamOutCallback;
-using ::android::hardware::audio::V4_0::MicrophoneInfo;
-using ::android::hardware::audio::V4_0::MmapBufferInfo;
-using ::android::hardware::audio::V4_0::MmapPosition;
-using ::android::hardware::audio::V4_0::ParameterValue;
-using ::android::hardware::audio::V4_0::Result;
-using ::android::hardware::audio::V4_0::SourceMetadata;
-using ::android::hardware::audio::V4_0::SinkMetadata;
-using ::android::hardware::audio::common::V4_0::AudioChannelMask;
-using ::android::hardware::audio::common::V4_0::AudioConfig;
-using ::android::hardware::audio::common::V4_0::AudioContentType;
-using ::android::hardware::audio::common::V4_0::AudioDevice;
-using ::android::hardware::audio::common::V4_0::AudioFormat;
-using ::android::hardware::audio::common::V4_0::AudioHandleConsts;
-using ::android::hardware::audio::common::V4_0::AudioHwSync;
-using ::android::hardware::audio::common::V4_0::AudioInputFlag;
-using ::android::hardware::audio::common::V4_0::AudioIoHandle;
-using ::android::hardware::audio::common::V4_0::AudioMode;
-using ::android::hardware::audio::common::V4_0::AudioOffloadInfo;
-using ::android::hardware::audio::common::V4_0::AudioOutputFlag;
-using ::android::hardware::audio::common::V4_0::AudioSource;
-using ::android::hardware::audio::common::V4_0::AudioUsage;
-using ::android::hardware::audio::common::V4_0::ThreadInfo;
-using ::android::hardware::audio::common::utils::mkBitfield;
+using ::android::hardware::audio::CPP_VERSION::AudioDrain;
+using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
+using ::android::hardware::audio::CPP_VERSION::IDevice;
+using ::android::hardware::audio::CPP_VERSION::IPrimaryDevice;
+using TtyMode = ::android::hardware::audio::CPP_VERSION::IPrimaryDevice::TtyMode;
+using ::android::hardware::audio::CPP_VERSION::IDevicesFactory;
+using ::android::hardware::audio::CPP_VERSION::IStream;
+using ::android::hardware::audio::CPP_VERSION::IStreamIn;
+using ::android::hardware::audio::CPP_VERSION::MessageQueueFlagBits;
+using ::android::hardware::audio::CPP_VERSION::TimeSpec;
+using ReadParameters = ::android::hardware::audio::CPP_VERSION::IStreamIn::ReadParameters;
+using ReadStatus = ::android::hardware::audio::CPP_VERSION::IStreamIn::ReadStatus;
+using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
+using ::android::hardware::audio::common::CPP_VERSION::AudioConfig;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioFormat;
+using ::android::hardware::audio::common::CPP_VERSION::AudioHandleConsts;
+using ::android::hardware::audio::common::CPP_VERSION::AudioHwSync;
+using ::android::hardware::audio::common::CPP_VERSION::AudioInputFlag;
+using ::android::hardware::audio::common::CPP_VERSION::AudioIoHandle;
+using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
+using ::android::hardware::audio::common::CPP_VERSION::AudioOffloadInfo;
+using ::android::hardware::audio::common::CPP_VERSION::AudioOutputFlag;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::common::CPP_VERSION::ThreadInfo;
+using ::android::hardware::audio::common::utils::mkEnumBitfield;
+using ::android::hardware::audio::CPP_VERSION::IStreamOut;
+using ::android::hardware::audio::CPP_VERSION::IStreamOutCallback;
+using ::android::hardware::audio::CPP_VERSION::MmapBufferInfo;
+using ::android::hardware::audio::CPP_VERSION::MmapPosition;
+using ::android::hardware::audio::CPP_VERSION::ParameterValue;
+using ::android::hardware::audio::CPP_VERSION::Result;
 
 using namespace ::android::hardware::audio::common::test::utility;
 
@@ -120,6 +128,10 @@
 static auto invalidArgsOrNotSupported = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED};
 static auto invalidStateOrNotSupported = {Result::INVALID_STATE, Result::NOT_SUPPORTED};
 
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////// Environment /////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
 class AudioHidlTestEnvironment : public ::Environment {
    public:
     virtual void registerTestServices() override { registerTestService<IDevicesFactory>(); }
@@ -135,11 +147,103 @@
 };
 
 //////////////////////////////////////////////////////////////////////////////
+////////////////////////// Audio policy configuration ////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+static const std::vector<const char*> kConfigLocations = {"/odm/etc", "/vendor/etc", "/system/etc"};
+static constexpr char kConfigFileName[] = "audio_policy_configuration.xml";
+
+// Stringify the argument.
+#define QUOTE(x) #x
+#define STRINGIFY(x) QUOTE(x)
+
+TEST(CheckConfig, audioPolicyConfigurationValidation) {
+    RecordProperty("description",
+                   "Verify that the audio policy configuration file "
+                   "is valid according to the schema");
+
+    const char* xsd = "/data/local/tmp/audio_policy_configuration_" STRINGIFY(CPP_VERSION) ".xsd";
+    EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(kConfigFileName, kConfigLocations, xsd);
+}
+
+struct PolicyConfigData {
+    android::HwModuleCollection hwModules;
+    android::DeviceVector availableOutputDevices;
+    android::DeviceVector availableInputDevices;
+    sp<android::DeviceDescriptor> defaultOutputDevice;
+    android::VolumeCurvesCollection volumes;
+};
+
+class PolicyConfig : private PolicyConfigData, public AudioPolicyConfig {
+   public:
+    PolicyConfig()
+        : AudioPolicyConfig(hwModules, availableOutputDevices, availableInputDevices,
+                            defaultOutputDevice, &volumes) {
+        for (const char* location : kConfigLocations) {
+            std::string path = std::string(location) + '/' + kConfigFileName;
+            if (access(path.c_str(), F_OK) == 0) {
+                mFilePath = path;
+                break;
+            }
+        }
+        mStatus = android::deserializeAudioPolicyFile(mFilePath.c_str(), this);
+        if (mStatus == OK) {
+            mPrimaryModule = getHwModules().getModuleFromName("primary");
+        }
+    }
+    status_t getStatus() const { return mStatus; }
+    std::string getError() const {
+        if (mFilePath.empty()) {
+            return std::string{"Could not find "} + kConfigFileName +
+                   " file in: " + testing::PrintToString(kConfigLocations);
+        } else {
+            return "Invalid config file: " + mFilePath;
+        }
+    }
+    const std::string& getFilePath() const { return mFilePath; }
+    sp<const HwModule> getPrimaryModule() const { return mPrimaryModule; }
+
+   private:
+    status_t mStatus = NO_INIT;
+    std::string mFilePath;
+    sp<HwModule> mPrimaryModule = nullptr;
+};
+
+// Cached policy config after parsing for faster test startup
+const PolicyConfig& getCachedPolicyConfig() {
+    static std::unique_ptr<PolicyConfig> policyConfig = [] {
+        auto config = std::make_unique<PolicyConfig>();
+        environment->registerTearDown([] { policyConfig.reset(); });
+        return config;
+    }();
+    return *policyConfig;
+}
+
+class AudioPolicyConfigTest : public HidlTest {
+   public:
+    void SetUp() override {
+        ASSERT_NO_FATAL_FAILURE(HidlTest::SetUp());  // setup base
+
+        auto& policyConfig = getCachedPolicyConfig();
+        ASSERT_EQ(0, policyConfig.getStatus()) << policyConfig.getError();
+
+        mPrimaryConfig = policyConfig.getPrimaryModule();
+        ASSERT_TRUE(mPrimaryConfig) << "Could not find primary module in configuration file: "
+                                    << policyConfig.getFilePath();
+    }
+    sp<const HwModule> mPrimaryConfig = nullptr;
+};
+
+TEST_F(AudioPolicyConfigTest, LoadAudioPolicyXMLConfiguration) {
+    doc::test("Test parsing audio_policy_configuration.xml (called in SetUp)");
+}
+
+//////////////////////////////////////////////////////////////////////////////
 ////////////////////// getService audio_devices_factory //////////////////////
 //////////////////////////////////////////////////////////////////////////////
 
 // Test all audio devices
-class AudioHidlTest : public HidlTest {
+class AudioHidlTest : public AudioPolicyConfigTest {
    public:
     void SetUp() override {
         ASSERT_NO_FATAL_FAILURE(HidlTest::SetUp());  // setup base
@@ -166,34 +270,16 @@
     doc::test("Test passing an invalid parameter to openDevice");
     Result result;
     sp<IDevice> device;
-    ASSERT_OK(devicesFactory->openDevice("Non existing device", returnIn(result, device)));
+#if MAJOR_VERSION == 2
+    auto invalidDevice = IDevicesFactory::Device(-1);
+#elif MAJOR_VERSION >= 4
+    auto invalidDevice = "Non existing device";
+#endif
+    ASSERT_OK(devicesFactory->openDevice(invalidDevice, returnIn(result, device)));
     ASSERT_EQ(Result::INVALID_ARGUMENTS, result);
     ASSERT_TRUE(device == nullptr);
 }
 
-TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {
-    doc::test("Calling openDevice(\"primary\") should return the primary device.");
-    {
-        Result result;
-        sp<IDevice> baseDevice;
-        ASSERT_OK(devicesFactory->openDevice("primary", returnIn(result, baseDevice)));
-        ASSERT_OK(result);
-        ASSERT_TRUE(baseDevice != nullptr);
-
-        Return<sp<IPrimaryDevice>> primaryDevice = IPrimaryDevice::castFrom(baseDevice);
-        ASSERT_TRUE(primaryDevice.isOk());
-        ASSERT_TRUE(sp<IPrimaryDevice>(primaryDevice) != nullptr);
-    }  // Destroy local IDevice proxy
-    // FIXME: there is no way to know when the remote IDevice is being destroyed
-    //        Binder does not support testing if an object is alive, thus
-    //        wait for 100ms to let the binder destruction propagates and
-    //        the remote device has the time to be destroyed.
-    //        flushCommand makes sure all local command are sent, thus should reduce
-    //        the latency between local and remote destruction.
-    IPCThreadState::self()->flushCommands();
-    usleep(100);
-}
-
 //////////////////////////////////////////////////////////////////////////////
 /////////////////////////////// openDevice primary ///////////////////////////
 //////////////////////////////////////////////////////////////////////////////
@@ -206,11 +292,8 @@
         ASSERT_NO_FATAL_FAILURE(AudioHidlTest::SetUp());  // setup base
 
         if (device == nullptr) {
-            Result result;
-            ASSERT_OK(devicesFactory->openPrimaryDevice(returnIn(result, device)));
-            ASSERT_OK(result);
+            initPrimaryDevice();
             ASSERT_TRUE(device != nullptr);
-
             environment->registerTearDown([] { device.clear(); });
         }
     }
@@ -218,6 +301,23 @@
    protected:
     // Cache the device opening to speed up each test by ~0.5s
     static sp<IPrimaryDevice> device;
+
+   private:
+    void initPrimaryDevice() {
+        Result result;
+#if MAJOR_VERSION == 2
+        sp<IDevice> baseDevice;
+        ASSERT_OK(devicesFactory->openDevice(IDevicesFactory::Device::PRIMARY,
+                                             returnIn(result, baseDevice)));
+        ASSERT_OK(result);
+        ASSERT_TRUE(baseDevice != nullptr);
+
+        device = IPrimaryDevice::castFrom(baseDevice);
+#elif MAJOR_VERSION >= 4
+        ASSERT_OK(devicesFactory->openPrimaryDevice(returnIn(result, device)));
+        ASSERT_OK(result);
+#endif
+    }
 };
 sp<IPrimaryDevice> AudioPrimaryHidlTest::device;
 
@@ -350,6 +450,20 @@
 
 class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest {
    public:
+    // for retro compatibility only test the primary device IN_BUILTIN_MIC
+    // FIXME: in the next audio HAL version, test all available devices
+    static bool primaryHasMic() {
+        auto& policyConfig = getCachedPolicyConfig();
+        if (policyConfig.getStatus() != OK || policyConfig.getPrimaryModule() == nullptr) {
+            return true;  // Could not get the information, run all tests
+        }
+        auto getMic = [](auto& devs) { return devs.getDevice(AUDIO_DEVICE_IN_BUILTIN_MIC, {}); };
+        auto primaryMic = getMic(policyConfig.getPrimaryModule()->getDeclaredDevices());
+        auto availableMic = getMic(policyConfig.getAvailableInputDevices());
+
+        return primaryMic != nullptr && primaryMic->equals(availableMic);
+    }
+
     // Cache result ?
     static const vector<AudioConfig> getRequiredSupportPlaybackAudioConfig() {
         return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
@@ -369,10 +483,12 @@
     }
 
     static const vector<AudioConfig> getRequiredSupportCaptureAudioConfig() {
+        if (!primaryHasMic()) return {};
         return combineAudioConfig({AudioChannelMask::IN_MONO}, {8000, 11025, 16000, 44100},
                                   {AudioFormat::PCM_16_BIT});
     }
     static const vector<AudioConfig> getRecommendedSupportCaptureAudioConfig() {
+        if (!primaryHasMic()) return {};
         return combineAudioConfig({AudioChannelMask::IN_STEREO}, {22050, 48000},
                                   {AudioFormat::PCM_16_BIT});
     }
@@ -392,7 +508,7 @@
                 for (auto format : formats) {
                     AudioConfig config{};
                     // leave offloadInfo to 0
-                    config.channelMask = mkBitfield(channelMask);
+                    config.channelMask = mkEnumBitfield(channelMask);
                     config.sampleRateHz = sampleRate;
                     config.format = format;
                     // FIXME: leave frameCount to 0 ?
@@ -413,8 +529,8 @@
     const AudioConfig& config = info.param;
     return to_string(info.index) + "__" + to_string(config.sampleRateHz) + "_" +
            // "MONO" is more clear than "FRONT_LEFT"
-           ((config.channelMask == mkBitfield(AudioChannelMask::OUT_MONO) ||
-             config.channelMask == mkBitfield(AudioChannelMask::IN_MONO))
+           ((config.channelMask == mkEnumBitfield(AudioChannelMask::OUT_MONO) ||
+             config.channelMask == mkEnumBitfield(AudioChannelMask::IN_MONO))
                 ? "MONO"
                 : ::testing::PrintToString(config.channelMask));
 }
@@ -501,91 +617,10 @@
     hidl_vec<ParameterValue> context;
     hidl_vec<hidl_string> keys;
     hidl_vec<ParameterValue> values;
-    ASSERT_OK(device->getParameters(context, keys, returnIn(res, values)));
-    ASSERT_OK(device->setParameters(context, values));
+    ASSERT_OK(Parameters::get(device, keys, returnIn(res, values)));
+    ASSERT_OK(Parameters::set(device, values));
     values.resize(0);
-    ASSERT_OK(device->setParameters(context, values));
-}
-
-//////////////////////////////////////////////////////////////////////////////
-/////////////////////////// get(Active)Microphones ///////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) {
-    doc::test("Make sure getMicrophones always succeeds");
-    hidl_vec<MicrophoneInfo> microphones;
-    ASSERT_OK(device->getMicrophones(returnIn(res, microphones)));
-    ASSERT_OK(res);
-    if (microphones.size() > 0) {
-        // When there is microphone on the phone, try to open an input stream
-        // and query for the active microphones.
-        doc::test(
-            "Make sure getMicrophones always succeeds"
-            "and getActiveMicrophones always succeeds when recording from these microphones.");
-        AudioIoHandle ioHandle = (AudioIoHandle)AudioHandleConsts::AUDIO_IO_HANDLE_NONE;
-        AudioConfig config{};
-        config.channelMask = mkBitfield(AudioChannelMask::IN_MONO);
-        config.sampleRateHz = 8000;
-        config.format = AudioFormat::PCM_16_BIT;
-        auto flags = hidl_bitfield<AudioInputFlag>(AudioInputFlag::NONE);
-        const SinkMetadata initialMetadata = {{{AudioSource::MIC, 1 /* gain */}}};
-        EventFlag* efGroup;
-        for (auto microphone : microphones) {
-            if (microphone.deviceAddress.device != AudioDevice::IN_BUILTIN_MIC) {
-                continue;
-            }
-            sp<IStreamIn> stream;
-            AudioConfig suggestedConfig{};
-            ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress, config, flags,
-                                              initialMetadata,
-                                              returnIn(res, stream, suggestedConfig)));
-            if (res != Result::OK) {
-                ASSERT_TRUE(stream == nullptr);
-                AudioConfig suggestedConfigRetry{};
-                ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress,
-                                                  suggestedConfig, flags, initialMetadata,
-                                                  returnIn(res, stream, suggestedConfigRetry)));
-            }
-            ASSERT_OK(res);
-            hidl_vec<MicrophoneInfo> activeMicrophones;
-            Result readRes;
-            typedef MessageQueue<ReadParameters, kSynchronizedReadWrite> CommandMQ;
-            typedef MessageQueue<uint8_t, kSynchronizedReadWrite> DataMQ;
-            std::unique_ptr<CommandMQ> commandMQ;
-            std::unique_ptr<DataMQ> dataMQ;
-            size_t frameSize = stream->getFrameSize();
-            size_t frameCount = stream->getBufferSize() / frameSize;
-            ASSERT_OK(stream->prepareForReading(
-                frameSize, frameCount, [&](auto r, auto& c, auto& d, auto&, auto&) {
-                    readRes = r;
-                    if (readRes == Result::OK) {
-                        commandMQ.reset(new CommandMQ(c));
-                        dataMQ.reset(new DataMQ(d));
-                        if (dataMQ->isValid() && dataMQ->getEventFlagWord()) {
-                            EventFlag::createEventFlag(dataMQ->getEventFlagWord(), &efGroup);
-                        }
-                    }
-                }));
-            ASSERT_OK(readRes);
-            ReadParameters params;
-            params.command = IStreamIn::ReadCommand::READ;
-            ASSERT_TRUE(commandMQ != nullptr);
-            ASSERT_TRUE(commandMQ->isValid());
-            ASSERT_TRUE(commandMQ->write(&params));
-            efGroup->wake(static_cast<uint32_t>(MessageQueueFlagBits::NOT_FULL));
-            uint32_t efState = 0;
-            efGroup->wait(static_cast<uint32_t>(MessageQueueFlagBits::NOT_EMPTY), &efState);
-            if (efState & static_cast<uint32_t>(MessageQueueFlagBits::NOT_EMPTY)) {
-                ASSERT_OK(stream->getActiveMicrophones(returnIn(res, activeMicrophones)));
-                ASSERT_OK(res);
-                ASSERT_NE(0U, activeMicrophones.size());
-            }
-            stream->close();
-            if (efGroup) {
-                EventFlag::deleteEventFlag(&efGroup);
-            }
-        }
-    }
+    ASSERT_OK(Parameters::set(device, values));
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -628,32 +663,12 @@
 
 TEST_F(AudioPrimaryHidlTest, DebugDump) {
     doc::test("Check that the hal can dump its state without error");
-    testDebugDump([](const auto& handle) { return device->debug(handle, {/* options */}); });
+    testDebugDump([](const auto& handle) { return dump(device, handle); });
 }
 
 TEST_F(AudioPrimaryHidlTest, DebugDumpInvalidArguments) {
     doc::test("Check that the hal dump doesn't crash on invalid arguments");
-    ASSERT_OK(device->debug(hidl_handle(), {/* options */}));
-}
-
-TEST_F(AudioPrimaryHidlTest, SetConnectedState) {
-    doc::test("Check that the HAL can be notified of device connection and deconnection");
-    using AD = AudioDevice;
-    for (auto deviceType : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) {
-        SCOPED_TRACE("device=" + ::testing::PrintToString(deviceType));
-        for (bool state : {true, false}) {
-            SCOPED_TRACE("state=" + ::testing::PrintToString(state));
-            DeviceAddress address = {};
-            address.device = deviceType;
-            auto ret = device->setConnectedState(address, state);
-            ASSERT_TRUE(ret.isOk());
-            if (ret == Result::NOT_SUPPORTED) {
-                doc::partialTest("setConnectedState is not supported");
-                return;
-            }
-            ASSERT_OK(ret);
-        }
-    }
+    ASSERT_OK(dump(device, hidl_handle()));
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -723,18 +738,25 @@
         address.device = AudioDevice::OUT_DEFAULT;
         const AudioConfig& config = GetParam();
         // TODO: test all flag combination
-        auto flags = hidl_bitfield<AudioOutputFlag>(AudioOutputFlag::NONE);
+        auto flags = mkEnumBitfield(AudioOutputFlag::NONE);
         testOpen(
             [&](AudioIoHandle handle, AudioConfig config, auto cb) {
-                return device->openOutputStream(handle, address, config, flags, initialMetadata,
-                                                cb);
+#if MAJOR_VERSION == 2
+                return device->openOutputStream(handle, address, config, flags, cb);
+#elif MAJOR_VERSION >= 4
+                return device->openOutputStream(handle, address, config, flags, initMetadata, cb);
+#endif
             },
             config);
     }
+#if MAJOR_VERSION >= 4
 
    protected:
-    const SourceMetadata initialMetadata = {
-        {{AudioUsage::MEDIA, AudioContentType::MUSIC, 1 /* gain */}}};
+    const SourceMetadata initMetadata = {
+        { { AudioUsage::MEDIA,
+            AudioContentType::MUSIC,
+            1 /* gain */ } }};
+#endif
 };
 TEST_P(OutputStreamTest, OpenOutputStreamTest) {
     doc::test(
@@ -764,16 +786,20 @@
         address.device = AudioDevice::IN_DEFAULT;
         const AudioConfig& config = GetParam();
         // TODO: test all supported flags and source
-        auto flags = hidl_bitfield<AudioInputFlag>(AudioInputFlag::NONE);
+        auto flags = mkEnumBitfield(AudioInputFlag::NONE);
         testOpen(
             [&](AudioIoHandle handle, AudioConfig config, auto cb) {
-                return device->openInputStream(handle, address, config, flags, initialMetadata, cb);
+                return device->openInputStream(handle, address, config, flags, initMetadata, cb);
             },
             config);
     }
 
    protected:
-    const SinkMetadata initialMetadata = {{{AudioSource::DEFAULT, 1 /* gain */}}};
+#if MAJOR_VERSION == 2
+    const AudioSource initMetadata = AudioSource::DEFAULT;
+#elif MAJOR_VERSION >= 4
+    const SinkMetadata initMetadata = {{{AudioSource::DEFAULT, 1 /* gain */}}};
+#endif
 };
 
 TEST_P(InputStreamTest, OpenInputStreamTest) {
@@ -842,19 +868,20 @@
 TEST_IO_STREAM(GetBufferSize, "Check that the stream buffer size== the one it was opened with",
                ASSERT_GE(extract(stream->getBufferSize()), extract(stream->getFrameSize())));
 
-template <class Property, class CapablityGetter>
+template <class Property, class CapabilityGetter>
 static void testCapabilityGetter(const string& name, IStream* stream,
-                                 CapablityGetter capablityGetter,
+                                 CapabilityGetter capabilityGetter,
                                  Return<Property> (IStream::*getter)(),
                                  Return<Result> (IStream::*setter)(Property),
                                  bool currentMustBeSupported = true) {
     hidl_vec<Property> capabilities;
-    auto ret = capablityGetter(stream, capabilities);
-    if (ret == Result::NOT_SUPPORTED) {
+    auto ret = capabilityGetter(stream, capabilities);
+    ASSERT_RESULT(okOrNotSupported, ret);
+    bool notSupported = ret == Result::NOT_SUPPORTED;
+    if (notSupported) {
         doc::partialTest(name + " is not supported");
         return;
     };
-    ASSERT_OK(ret);
 
     if (currentMustBeSupported) {
         ASSERT_NE(0U, capabilities.size()) << name << " must not return an empty list";
@@ -878,29 +905,9 @@
     }
 }
 
-Result getSupportedSampleRates(IStream* stream, hidl_vec<uint32_t>& rates) {
-    Result res;
-    EXPECT_OK(stream->getSupportedSampleRates(extract(stream->getFormat()), returnIn(res, rates)));
-    return res;
-}
-
-Result getSupportedChannelMasks(IStream* stream,
-                                hidl_vec<hidl_bitfield<AudioChannelMask>>& channels) {
-    Result res;
-    EXPECT_OK(
-        stream->getSupportedChannelMasks(extract(stream->getFormat()), returnIn(res, channels)));
-    return res;
-}
-
-Result getSupportedFormats(IStream* stream, hidl_vec<AudioFormat>& capabilities) {
-    EXPECT_OK(stream->getSupportedFormats(returnIn(capabilities)));
-    // TODO: this should be an optional function
-    return Result::OK;
-}
-
 TEST_IO_STREAM(SupportedSampleRate, "Check that the stream sample rate is declared as supported",
                testCapabilityGetter("getSupportedSampleRate", stream.get(),
-                                    &getSupportedSampleRates, &IStream::getSampleRate,
+                                    &GetSupported::sampleRates, &IStream::getSampleRate,
                                     &IStream::setSampleRate,
                                     // getSupportedSampleRate returns the native sampling rates,
                                     // (the sampling rates that can be played without resampling)
@@ -909,48 +916,16 @@
 
 TEST_IO_STREAM(SupportedChannelMask, "Check that the stream channel mask is declared as supported",
                testCapabilityGetter("getSupportedChannelMask", stream.get(),
-                                    &getSupportedChannelMasks, &IStream::getChannelMask,
+                                    &GetSupported::channelMasks, &IStream::getChannelMask,
                                     &IStream::setChannelMask))
 
 TEST_IO_STREAM(SupportedFormat, "Check that the stream format is declared as supported",
-               testCapabilityGetter("getSupportedFormat", stream.get(), &getSupportedFormats,
+               testCapabilityGetter("getSupportedFormat", stream.get(), &GetSupported::formats,
                                     &IStream::getFormat, &IStream::setFormat))
 
-static void testGetDevices(IStream* stream, AudioDevice expectedDevice) {
-    hidl_vec<DeviceAddress> devices;
-    Result res;
-    ASSERT_OK(stream->getDevices(returnIn(res, devices)));
-    if (res == Result::NOT_SUPPORTED) {
-        return doc::partialTest("GetDevices is not supported");
-    }
-    // The stream was constructed with one device, thus getDevices must only return one
-    ASSERT_EQ(1U, devices.size());
-    AudioDevice device = devices[0].device;
-    ASSERT_TRUE(device == expectedDevice)
-        << "Expected: " << ::testing::PrintToString(expectedDevice)
-        << "\n  Actual: " << ::testing::PrintToString(device);
-}
-
-TEST_IO_STREAM(GetDevices, "Check that the stream device == the one it was opened with",
-               areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
-                                          : testGetDevices(stream.get(), address.device))
-
-static void testSetDevices(IStream* stream, const DeviceAddress& address) {
-    DeviceAddress otherAddress = address;
-    otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER
-                                                                      : AudioDevice::IN_BUILTIN_MIC;
-    EXPECT_OK(stream->setDevices({otherAddress}));
-
-    ASSERT_OK(stream->setDevices({address}));  // Go back to the original value
-}
-
-TEST_IO_STREAM(SetDevices, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
-               areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
-                                          : testSetDevices(stream.get(), address))
-
 static void testGetAudioProperties(IStream* stream, AudioConfig expectedConfig) {
     uint32_t sampleRateHz;
-    hidl_bitfield<AudioChannelMask> mask;
+    auto mask = mkEnumBitfield<AudioChannelMask>({});
     AudioFormat format;
 
     stream->getAudioProperties(returnIn(sampleRateHz, mask, format));
@@ -969,23 +944,11 @@
 TEST_IO_STREAM(SetHwAvSync, "Try to set hardware sync to an invalid value",
                ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, stream->setHwAvSync(666)))
 
-static void checkGetHwAVSync(IDevice* device) {
-    Result res;
-    AudioHwSync sync;
-    ASSERT_OK(device->getHwAvSync(returnIn(res, sync)));
-    if (res == Result::NOT_SUPPORTED) {
-        return doc::partialTest("getHwAvSync is not supported");
-    }
-    ASSERT_OK(res);
-}
-TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", checkGetHwAVSync(device.get()));
-
 static void checkGetNoParameter(IStream* stream, hidl_vec<hidl_string> keys,
                                 initializer_list<Result> expectedResults) {
-    hidl_vec<ParameterValue> context;
     hidl_vec<ParameterValue> parameters;
     Result res;
-    ASSERT_OK(stream->getParameters(context, keys, returnIn(res, parameters)));
+    ASSERT_OK(Parameters::get(stream, keys, returnIn(res, parameters)));
     ASSERT_RESULT(expectedResults, res);
     if (res == Result::OK) {
         for (auto& parameter : parameters) {
@@ -1006,7 +969,7 @@
                                    {Result::NOT_SUPPORTED}))
 
 TEST_IO_STREAM(setEmptySetParameter, "Set the values of an empty set of parameters",
-               ASSERT_RESULT(Result::OK, stream->setParameters({}, {})))
+               ASSERT_RESULT(Result::OK, Parameters::set(stream, {})))
 
 TEST_IO_STREAM(setNonExistingParameter, "Set the values of an non existing parameter",
                // Unfortunately, the set_parameter legacy interface did not return any
@@ -1014,14 +977,14 @@
                // To allow implementation to just wrapped the legacy one, consider OK as a
                // valid result for setting a non existing parameter.
                ASSERT_RESULT(okOrNotSupportedOrInvalidArgs,
-                             stream->setParameters({}, {{"non existing key", "0"}})))
+                             Parameters::set(stream, {{"non existing key", "0"}})))
 
 TEST_IO_STREAM(DebugDump, "Check that a stream can dump its state without error",
-               testDebugDump([this](const auto& handle) { return stream->debug(handle, {}); }))
+               testDebugDump([this](const auto& handle) { return dump(stream, handle); }))
 
 TEST_IO_STREAM(DebugDumpInvalidArguments,
                "Check that the stream dump doesn't crash on invalid arguments",
-               ASSERT_OK(stream->debug(hidl_handle(), {})))
+               ASSERT_OK(dump(stream, hidl_handle())))
 
 //////////////////////////////////////////////////////////////////////////////
 ////////////////////////////// addRemoveEffect ///////////////////////////////
@@ -1171,28 +1134,6 @@
     }
 }
 
-TEST_P(InputStreamTest, updateSinkMetadata) {
-    doc::test("The HAL should not crash on metadata change");
-
-    hidl_enum_range<AudioSource> range;
-    // Test all possible track configuration
-    for (AudioSource source : range) {
-        for (float volume : {0.0, 0.5, 1.0}) {
-            const SinkMetadata metadata = {{{source, volume}}};
-            ASSERT_OK(stream->updateSinkMetadata(metadata))
-                << "source=" << toString(source) << ", volume=" << volume;
-        }
-    }
-
-    // Do not test concurrent capture as this is not officially supported
-
-    // Set no metadata as if all stream track had stopped
-    ASSERT_OK(stream->updateSinkMetadata({}));
-
-    // Restore initial
-    ASSERT_OK(stream->updateSinkMetadata(initialMetadata));
-}
-
 //////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////// StreamOut //////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////
@@ -1410,42 +1351,6 @@
     ASSERT_PRED2([](auto c, auto m) { return c - m < 1e+6; }, currentTime, mesureTime);
 }
 
-TEST_P(OutputStreamTest, SelectPresentation) {
-    doc::test("Verify that presentation selection does not crash");
-    ASSERT_RESULT(okOrNotSupported, stream->selectPresentation(0, 0));
-}
-
-TEST_P(OutputStreamTest, updateSourceMetadata) {
-    doc::test("The HAL should not crash on metadata change");
-
-    hidl_enum_range<AudioUsage> usageRange;
-    hidl_enum_range<AudioContentType> contentRange;
-    // Test all possible track configuration
-    for (auto usage : usageRange) {
-        for (auto content : contentRange) {
-            for (float volume : {0.0, 0.5, 1.0}) {
-                const SourceMetadata metadata = {{{usage, content, volume}}};
-                ASSERT_OK(stream->updateSourceMetadata(metadata))
-                    << "usage=" << toString(usage) << ", content=" << toString(content)
-                    << ", volume=" << volume;
-            }
-        }
-    }
-
-    // Set many track of different configuration
-    ASSERT_OK(stream->updateSourceMetadata(
-        {{{AudioUsage::MEDIA, AudioContentType::MUSIC, 0.1},
-          {AudioUsage::VOICE_COMMUNICATION, AudioContentType::SPEECH, 1.0},
-          {AudioUsage::ALARM, AudioContentType::SONIFICATION, 0.0},
-          {AudioUsage::ASSISTANT, AudioContentType::UNKNOWN, 0.3}}}));
-
-    // Set no metadata as if all stream track had stopped
-    ASSERT_OK(stream->updateSourceMetadata({}));
-
-    // Restore initial
-    ASSERT_OK(stream->updateSourceMetadata(initialMetadata));
-}
-
 //////////////////////////////////////////////////////////////////////////////
 /////////////////////////////// PrimaryDevice ////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////
@@ -1455,57 +1360,6 @@
     testUnitaryGain([](float volume) { return device->setVoiceVolume(volume); });
 }
 
-TEST_F(AudioPrimaryHidlTest, setMode) {
-    doc::test("Make sure setMode always succeeds if mode is valid and fails otherwise");
-    // Test Invalid values
-    for (int mode : {-2, -1, int(AudioMode::IN_COMMUNICATION) + 1}) {
-        ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(AudioMode(mode)))
-            << "mode=" << mode;
-    }
-    // Test valid values
-    for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE,
-                           AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) {
-        ASSERT_OK(device->setMode(mode)) << "mode=" << toString(mode);
-    }
-}
-
-TEST_F(AudioPrimaryHidlTest, setBtHfpSampleRate) {
-    doc::test(
-        "Make sure setBtHfpSampleRate either succeeds or "
-        "indicates that it is not supported at all, or that the provided value is invalid");
-    for (auto samplingRate : {8000, 16000, 22050, 24000}) {
-        ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, device->setBtHfpSampleRate(samplingRate));
-    }
-}
-
-TEST_F(AudioPrimaryHidlTest, setBtHfpVolume) {
-    doc::test(
-        "Make sure setBtHfpVolume is either not supported or "
-        "only succeed if volume is in [0,1]");
-    auto ret = device->setBtHfpVolume(0.0);
-    ASSERT_TRUE(ret.isOk());
-    if (ret == Result::NOT_SUPPORTED) {
-        doc::partialTest("setBtHfpVolume is not supported");
-        return;
-    }
-    testUnitaryGain([](float volume) { return device->setBtHfpVolume(volume); });
-}
-
-TEST_F(AudioPrimaryHidlTest, setBtScoHeadsetDebugName) {
-    doc::test(
-        "Make sure setBtScoHeadsetDebugName either succeeds or "
-        "indicates that it is not supported");
-    ASSERT_RESULT(okOrNotSupported, device->setBtScoHeadsetDebugName("test"));
-}
-
-TEST_F(AudioPrimaryHidlTest, updateRotation) {
-    doc::test("Check that the hal can receive the current rotation");
-    for (Rotation rotation : {Rotation::DEG_0, Rotation::DEG_90, Rotation::DEG_180,
-                              Rotation::DEG_270, Rotation::DEG_0}) {
-        ASSERT_RESULT(okOrNotSupported, device->updateRotation(rotation));
-    }
-}
-
 TEST_F(BoolAccessorPrimaryHidlTest, BtScoNrecEnabled) {
     doc::test("Query and set the BT SCO NR&EC state");
     testAccessors<OPTIONAL>("BtScoNrecEnabled", Initial{false, OPTIONAL}, {true},
@@ -1520,12 +1374,6 @@
                             &IPrimaryDevice::getBtScoWidebandEnabled);
 }
 
-TEST_F(BoolAccessorPrimaryHidlTest, setGetBtHfpEnabled) {
-    doc::test("Query and set the BT HFP state");
-    testAccessors<OPTIONAL>("BtHfpEnabled", Initial{false, OPTIONAL}, {true},
-                            &IPrimaryDevice::setBtHfpEnabled, &IPrimaryDevice::getBtHfpEnabled);
-}
-
 using TtyModeAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<TtyMode>;
 TEST_F(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) {
     doc::test("Query and set the TTY mode state");
diff --git a/audio/effect/2.0/default/AcousticEchoCancelerEffect.cpp b/audio/effect/2.0/default/AcousticEchoCancelerEffect.cpp
deleted file mode 100644
index cadc2f1..0000000
--- a/audio/effect/2.0/default/AcousticEchoCancelerEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "AEC_Effect_HAL"
-
-#include "AcousticEchoCancelerEffect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/AcousticEchoCancelerEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/AcousticEchoCancelerEffect.h b/audio/effect/2.0/default/AcousticEchoCancelerEffect.h
deleted file mode 100644
index d36335c..0000000
--- a/audio/effect/2.0/default/AcousticEchoCancelerEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_ACOUSTICECHOCANCELEREFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_ACOUSTICECHOCANCELEREFFECT_H
-
-#include <android/hardware/audio/effect/2.0/IAcousticEchoCancelerEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/AcousticEchoCancelerEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_ACOUSTICECHOCANCELEREFFECT_H
diff --git a/audio/effect/2.0/default/Android.bp b/audio/effect/2.0/default/Android.bp
deleted file mode 100644
index db00988..0000000
--- a/audio/effect/2.0/default/Android.bp
+++ /dev/null
@@ -1,50 +0,0 @@
-cc_library_shared {
-    name: "android.hardware.audio.effect@2.0-impl",
-    defaults: ["hidl_defaults"],
-    vendor: true,
-    relative_install_path: "hw",
-    srcs: [
-        "AcousticEchoCancelerEffect.cpp",
-        "AudioBufferManager.cpp",
-        "AutomaticGainControlEffect.cpp",
-        "BassBoostEffect.cpp",
-        "Conversions.cpp",
-        "DownmixEffect.cpp",
-        "Effect.cpp",
-        "EffectsFactory.cpp",
-        "EnvironmentalReverbEffect.cpp",
-        "EqualizerEffect.cpp",
-        "LoudnessEnhancerEffect.cpp",
-        "NoiseSuppressionEffect.cpp",
-        "PresetReverbEffect.cpp",
-        "VirtualizerEffect.cpp",
-        "VisualizerEffect.cpp",
-    ],
-
-    shared_libs: [
-        "libbase",
-        "libcutils",
-        "libeffects",
-        "libfmq",
-        "libhidlbase",
-        "libhidlmemory",
-        "libhidltransport",
-        "liblog",
-        "libutils",
-        "android.hardware.audio.common-util",
-        "android.hardware.audio.common@2.0",
-        "android.hardware.audio.common@2.0-util",
-        "android.hardware.audio.effect@2.0",
-        "android.hidl.memory@1.0",
-    ],
-
-    header_libs: [
-        "android.hardware.audio.common.util@all-versions",
-        "android.hardware.audio.effect@all-versions-impl",
-        "libaudio_system_headers",
-        "libaudioclient_headers",
-        "libeffects_headers",
-        "libhardware_headers",
-        "libmedia_headers",
-    ],
-}
diff --git a/audio/effect/2.0/default/AudioBufferManager.cpp b/audio/effect/2.0/default/AudioBufferManager.cpp
deleted file mode 100644
index 39918dd..0000000
--- a/audio/effect/2.0/default/AudioBufferManager.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "AudioBufferManager.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/AudioBufferManager.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/AudioBufferManager.h b/audio/effect/2.0/default/AudioBufferManager.h
deleted file mode 100644
index 789fbd1..0000000
--- a/audio/effect/2.0/default/AudioBufferManager.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUDIO_BUFFER_MANAGER_H_
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUDIO_BUFFER_MANAGER_H_
-
-#include <android/hardware/audio/effect/2.0/types.h>
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/AudioBufferManager.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUDIO_BUFFER_MANAGER_H_
diff --git a/audio/effect/2.0/default/AutomaticGainControlEffect.cpp b/audio/effect/2.0/default/AutomaticGainControlEffect.cpp
deleted file mode 100644
index 7e00a80..0000000
--- a/audio/effect/2.0/default/AutomaticGainControlEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "AGC_Effect_HAL"
-
-#include "AutomaticGainControlEffect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/AutomaticGainControlEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/AutomaticGainControlEffect.h b/audio/effect/2.0/default/AutomaticGainControlEffect.h
deleted file mode 100644
index ef440d2..0000000
--- a/audio/effect/2.0/default/AutomaticGainControlEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H
-
-#include <android/hardware/audio/effect/2.0/IAutomaticGainControlEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/AutomaticGainControlEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H
diff --git a/audio/effect/2.0/default/BassBoostEffect.cpp b/audio/effect/2.0/default/BassBoostEffect.cpp
deleted file mode 100644
index df9e892..0000000
--- a/audio/effect/2.0/default/BassBoostEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "BassBoost_HAL"
-
-#include "BassBoostEffect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/BassBoostEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/BassBoostEffect.h b/audio/effect/2.0/default/BassBoostEffect.h
deleted file mode 100644
index 83179e2..0000000
--- a/audio/effect/2.0/default/BassBoostEffect.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_BASSBOOSTEFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_BASSBOOSTEFFECT_H
-
-#include <android/hardware/audio/effect/2.0/IBassBoostEffect.h>
-
-#include <hidl/MQDescriptor.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/BassBoostEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_BASSBOOSTEFFECT_H
diff --git a/audio/effect/2.0/default/Conversions.cpp b/audio/effect/2.0/default/Conversions.cpp
deleted file mode 100644
index b59752c..0000000
--- a/audio/effect/2.0/default/Conversions.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "Conversions.h"
-#include "HidlUtils.h"
-
-using ::android::hardware::audio::common::V2_0::HidlUtils;
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/Conversions.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/Conversions.h b/audio/effect/2.0/default/Conversions.h
deleted file mode 100644
index 94c7f66..0000000
--- a/audio/effect/2.0/default/Conversions.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_CONVERSIONS_H_
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_CONVERSIONS_H_
-
-#include <android/hardware/audio/effect/2.0/types.h>
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/Conversions.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_CONVERSIONS_H_
diff --git a/audio/effect/2.0/default/DownmixEffect.cpp b/audio/effect/2.0/default/DownmixEffect.cpp
deleted file mode 100644
index 1a51e13..0000000
--- a/audio/effect/2.0/default/DownmixEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "Downmix_HAL"
-
-#include "DownmixEffect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/DownmixEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/DownmixEffect.h b/audio/effect/2.0/default/DownmixEffect.h
deleted file mode 100644
index 6dbbb32..0000000
--- a/audio/effect/2.0/default/DownmixEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_DOWNMIXEFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_DOWNMIXEFFECT_H
-
-#include <android/hardware/audio/effect/2.0/IDownmixEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/DownmixEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_DOWNMIXEFFECT_H
diff --git a/audio/effect/2.0/default/Effect.cpp b/audio/effect/2.0/default/Effect.cpp
deleted file mode 100644
index e234e52..0000000
--- a/audio/effect/2.0/default/Effect.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <memory.h>
-
-#define LOG_TAG "EffectHAL"
-#define ATRACE_TAG ATRACE_TAG_AUDIO
-
-#include "Conversions.h"
-#include "Effect.h"
-#include "common/all-versions/default/EffectMap.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/Effect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/Effect.h b/audio/effect/2.0/default/Effect.h
deleted file mode 100644
index a4d194d..0000000
--- a/audio/effect/2.0/default/Effect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECT_H
-
-#include <android/hardware/audio/effect/2.0/IEffect.h>
-
-#include "AudioBufferManager.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/Effect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECT_H
diff --git a/audio/effect/2.0/default/EffectsFactory.cpp b/audio/effect/2.0/default/EffectsFactory.cpp
deleted file mode 100644
index a48a85f..0000000
--- a/audio/effect/2.0/default/EffectsFactory.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "EffectFactoryHAL"
-#include "EffectsFactory.h"
-#include "AcousticEchoCancelerEffect.h"
-#include "AutomaticGainControlEffect.h"
-#include "BassBoostEffect.h"
-#include "Conversions.h"
-#include "DownmixEffect.h"
-#include "Effect.h"
-#include "EnvironmentalReverbEffect.h"
-#include "EqualizerEffect.h"
-#include "HidlUtils.h"
-#include "LoudnessEnhancerEffect.h"
-#include "NoiseSuppressionEffect.h"
-#include "PresetReverbEffect.h"
-#include "VirtualizerEffect.h"
-#include "VisualizerEffect.h"
-#include "common/all-versions/default/EffectMap.h"
-
-using ::android::hardware::audio::common::V2_0::HidlUtils;
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/EffectsFactory.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/EffectsFactory.h b/audio/effect/2.0/default/EffectsFactory.h
deleted file mode 100644
index f1bfbcf..0000000
--- a/audio/effect/2.0/default/EffectsFactory.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECTSFACTORY_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECTSFACTORY_H
-
-#include <system/audio_effect.h>
-
-#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
-
-#include <hidl/MQDescriptor.h>
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/EffectsFactory.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECTSFACTORY_H
diff --git a/audio/effect/2.0/default/EnvironmentalReverbEffect.cpp b/audio/effect/2.0/default/EnvironmentalReverbEffect.cpp
deleted file mode 100644
index 017dd1f..0000000
--- a/audio/effect/2.0/default/EnvironmentalReverbEffect.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "EnvReverb_HAL"
-#include <android/log.h>
-
-#include "EnvironmentalReverbEffect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/EnvironmentalReverbEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/EnvironmentalReverbEffect.h b/audio/effect/2.0/default/EnvironmentalReverbEffect.h
deleted file mode 100644
index d93a53f..0000000
--- a/audio/effect/2.0/default/EnvironmentalReverbEffect.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_ENVIRONMENTALREVERBEFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_ENVIRONMENTALREVERBEFFECT_H
-
-#include <system/audio_effects/effect_environmentalreverb.h>
-
-#include <android/hardware/audio/effect/2.0/IEnvironmentalReverbEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/EnvironmentalReverbEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_ENVIRONMENTALREVERBEFFECT_H
diff --git a/audio/effect/2.0/default/EqualizerEffect.cpp b/audio/effect/2.0/default/EqualizerEffect.cpp
deleted file mode 100644
index d6e056c..0000000
--- a/audio/effect/2.0/default/EqualizerEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "Equalizer_HAL"
-
-#include "EqualizerEffect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/EqualizerEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/EqualizerEffect.h b/audio/effect/2.0/default/EqualizerEffect.h
deleted file mode 100644
index 54cdd50..0000000
--- a/audio/effect/2.0/default/EqualizerEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EQUALIZEREFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EQUALIZEREFFECT_H
-
-#include <android/hardware/audio/effect/2.0/IEqualizerEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/EqualizerEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EQUALIZEREFFECT_H
diff --git a/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp b/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp
deleted file mode 100644
index 2dca0f4..0000000
--- a/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "LoudnessEnhancer_HAL"
-
-#include "LoudnessEnhancerEffect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/LoudnessEnhancerEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/LoudnessEnhancerEffect.h b/audio/effect/2.0/default/LoudnessEnhancerEffect.h
deleted file mode 100644
index 992e238..0000000
--- a/audio/effect/2.0/default/LoudnessEnhancerEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_LOUDNESSENHANCEREFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_LOUDNESSENHANCEREFFECT_H
-
-#include <android/hardware/audio/effect/2.0/ILoudnessEnhancerEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/LoudnessEnhancerEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_LOUDNESSENHANCEREFFECT_H
diff --git a/audio/effect/2.0/default/NoiseSuppressionEffect.cpp b/audio/effect/2.0/default/NoiseSuppressionEffect.cpp
deleted file mode 100644
index 089e811..0000000
--- a/audio/effect/2.0/default/NoiseSuppressionEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "NS_Effect_HAL"
-
-#include "NoiseSuppressionEffect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/NoiseSuppressionEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/NoiseSuppressionEffect.h b/audio/effect/2.0/default/NoiseSuppressionEffect.h
deleted file mode 100644
index 0eee4b5..0000000
--- a/audio/effect/2.0/default/NoiseSuppressionEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_NOISESUPPRESSIONEFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_NOISESUPPRESSIONEFFECT_H
-
-#include <android/hardware/audio/effect/2.0/INoiseSuppressionEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/NoiseSuppressionEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_NOISESUPPRESSIONEFFECT_H
diff --git a/audio/effect/2.0/default/OWNERS b/audio/effect/2.0/default/OWNERS
deleted file mode 100644
index 6fdc97c..0000000
--- a/audio/effect/2.0/default/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-elaurent@google.com
-krocard@google.com
-mnaganov@google.com
diff --git a/audio/effect/2.0/default/PresetReverbEffect.cpp b/audio/effect/2.0/default/PresetReverbEffect.cpp
deleted file mode 100644
index 0648f6a..0000000
--- a/audio/effect/2.0/default/PresetReverbEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "PresetReverb_HAL"
-
-#include "PresetReverbEffect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/PresetReverbEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/PresetReverbEffect.h b/audio/effect/2.0/default/PresetReverbEffect.h
deleted file mode 100644
index 1ea1626..0000000
--- a/audio/effect/2.0/default/PresetReverbEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_PRESETREVERBEFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_PRESETREVERBEFFECT_H
-
-#include <android/hardware/audio/effect/2.0/IPresetReverbEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/PresetReverbEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_PRESETREVERBEFFECT_H
diff --git a/audio/effect/2.0/default/VirtualizerEffect.cpp b/audio/effect/2.0/default/VirtualizerEffect.cpp
deleted file mode 100644
index 63d3eb9..0000000
--- a/audio/effect/2.0/default/VirtualizerEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "Virtualizer_HAL"
-
-#include "VirtualizerEffect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/VirtualizerEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/VirtualizerEffect.h b/audio/effect/2.0/default/VirtualizerEffect.h
deleted file mode 100644
index 04f93c4..0000000
--- a/audio/effect/2.0/default/VirtualizerEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VIRTUALIZEREFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VIRTUALIZEREFFECT_H
-
-#include <android/hardware/audio/effect/2.0/IVirtualizerEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/VirtualizerEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VIRTUALIZEREFFECT_H
diff --git a/audio/effect/2.0/default/VisualizerEffect.cpp b/audio/effect/2.0/default/VisualizerEffect.cpp
deleted file mode 100644
index 5235524..0000000
--- a/audio/effect/2.0/default/VisualizerEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "Visualizer_HAL"
-
-#include "VisualizerEffect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/VisualizerEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/2.0/default/VisualizerEffect.h b/audio/effect/2.0/default/VisualizerEffect.h
deleted file mode 100644
index 940f15d..0000000
--- a/audio/effect/2.0/default/VisualizerEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VISUALIZEREFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VISUALIZEREFFECT_H
-
-#include <android/hardware/audio/effect/2.0/IVisualizerEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V2_0
-#include <effect/all-versions/default/VisualizerEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VISUALIZEREFFECT_H
diff --git a/audio/effect/2.0/vts/OWNERS b/audio/effect/2.0/vts/OWNERS
deleted file mode 100644
index 8711a9f..0000000
--- a/audio/effect/2.0/vts/OWNERS
+++ /dev/null
@@ -1,5 +0,0 @@
-elaurent@google.com
-krocard@google.com
-mnaganov@google.com
-yim@google.com
-zhuoyao@google.com
\ No newline at end of file
diff --git a/audio/effect/2.0/vts/functional/Android.bp b/audio/effect/2.0/vts/functional/Android.bp
deleted file mode 100644
index 51d2e11..0000000
--- a/audio/effect/2.0/vts/functional/Android.bp
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// 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.
-//
-
-cc_test {
-    name: "VtsHalAudioEffectV2_0TargetTest",
-    defaults: ["VtsHalTargetTestDefaults"],
-    srcs: [
-        "VtsHalAudioEffectV2_0TargetTest.cpp",
-        "ValidateAudioEffectsConfiguration.cpp"
-    ],
-    static_libs: [
-        "android.hardware.audio.common.test.utility",
-        "android.hardware.audio.common@2.0",
-        "android.hardware.audio.effect@2.0",
-        "android.hidl.allocator@1.0",
-        "android.hidl.memory@1.0",
-        "libeffectsconfig",
-        "libicuuc",
-        "libicuuc_stubdata",
-        "libxml2",
-    ],
-}
diff --git a/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp b/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp
deleted file mode 100644
index bf080d3..0000000
--- a/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <unistd.h>
-#include <iterator>
-
-#include <media/EffectsConfig.h>
-
-#include "utility/ValidateXml.h"
-
-TEST(CheckConfig, audioEffectsConfigurationValidation) {
-    RecordProperty("description",
-                   "Verify that the effects configuration file is valid according to the schema");
-    using namespace android::effectsConfig;
-
-    std::vector<const char*> locations(std::begin(DEFAULT_LOCATIONS), std::end(DEFAULT_LOCATIONS));
-    EXPECT_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations,
-                                        "/data/local/tmp/audio_effects_conf_V2_0.xsd");
-}
diff --git a/audio/effect/2.0/vts/functional/VtsHalAudioEffectV2_0TargetTest.cpp b/audio/effect/2.0/vts/functional/VtsHalAudioEffectV2_0TargetTest.cpp
deleted file mode 100644
index c90c4fa..0000000
--- a/audio/effect/2.0/vts/functional/VtsHalAudioEffectV2_0TargetTest.cpp
+++ /dev/null
@@ -1,849 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "AudioEffectHidlHalTest"
-#include <android-base/logging.h>
-#include <system/audio.h>
-
-#include <android/hardware/audio/effect/2.0/IEffect.h>
-#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
-#include <android/hardware/audio/effect/2.0/IEqualizerEffect.h>
-#include <android/hardware/audio/effect/2.0/ILoudnessEnhancerEffect.h>
-#include <android/hardware/audio/effect/2.0/types.h>
-#include <android/hidl/allocator/1.0/IAllocator.h>
-#include <android/hidl/memory/1.0/IMemory.h>
-
-#include <VtsHalHidlTargetTestBase.h>
-#include <VtsHalHidlTargetTestEnvBase.h>
-
-using android::hardware::audio::common::V2_0::AudioDevice;
-using android::hardware::audio::common::V2_0::AudioHandleConsts;
-using android::hardware::audio::common::V2_0::AudioMode;
-using android::hardware::audio::common::V2_0::AudioSource;
-using android::hardware::audio::common::V2_0::Uuid;
-using android::hardware::audio::effect::V2_0::AudioBuffer;
-using android::hardware::audio::effect::V2_0::EffectAuxChannelsConfig;
-using android::hardware::audio::effect::V2_0::EffectBufferConfig;
-using android::hardware::audio::effect::V2_0::EffectConfig;
-using android::hardware::audio::effect::V2_0::EffectDescriptor;
-using android::hardware::audio::effect::V2_0::EffectOffloadParameter;
-using android::hardware::audio::effect::V2_0::IEffect;
-using android::hardware::audio::effect::V2_0::IEffectsFactory;
-using android::hardware::audio::effect::V2_0::IEqualizerEffect;
-using android::hardware::audio::effect::V2_0::ILoudnessEnhancerEffect;
-using android::hardware::audio::effect::V2_0::Result;
-using android::hardware::MQDescriptorSync;
-using android::hardware::Return;
-using android::hardware::Void;
-using android::hardware::hidl_handle;
-using android::hardware::hidl_memory;
-using android::hardware::hidl_string;
-using android::hardware::hidl_vec;
-using android::hidl::allocator::V1_0::IAllocator;
-using android::hidl::memory::V1_0::IMemory;
-using android::sp;
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
-#endif
-
-// Test environment for Audio Effects Factory HIDL HAL.
-class AudioEffectsFactoryHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
-   public:
-    // get the test environment singleton
-    static AudioEffectsFactoryHidlEnvironment* Instance() {
-        static AudioEffectsFactoryHidlEnvironment* instance =
-            new AudioEffectsFactoryHidlEnvironment;
-        return instance;
-    }
-
-    virtual void registerTestServices() override { registerTestService<IEffectsFactory>(); }
-};
-
-// The main test class for Audio Effects Factory HIDL HAL.
-class AudioEffectsFactoryHidlTest : public ::testing::VtsHalHidlTargetTestBase {
- public:
-  void SetUp() override {
-      effectsFactory = ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>(
-          AudioEffectsFactoryHidlEnvironment::Instance()->getServiceName<IEffectsFactory>());
-      ASSERT_NE(effectsFactory, nullptr);
-  }
-
-  void TearDown() override { effectsFactory.clear(); }
-
- protected:
-  static void description(const std::string& description) {
-    RecordProperty("description", description);
-  }
-
-  sp<IEffectsFactory> effectsFactory;
-};
-
-TEST_F(AudioEffectsFactoryHidlTest, EnumerateEffects) {
-  description("Verify that EnumerateEffects returns at least one effect");
-  Result retval = Result::NOT_INITIALIZED;
-  size_t effectCount = 0;
-  Return<void> ret = effectsFactory->getAllDescriptors(
-      [&](Result r, const hidl_vec<EffectDescriptor>& result) {
-        retval = r;
-        effectCount = result.size();
-      });
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  EXPECT_GT(effectCount, 0u);
-}
-
-TEST_F(AudioEffectsFactoryHidlTest, CreateEffect) {
-  description("Verify that an effect can be created via CreateEffect");
-  bool gotEffect = false;
-  Uuid effectUuid;
-  Return<void> ret = effectsFactory->getAllDescriptors(
-      [&](Result r, const hidl_vec<EffectDescriptor>& result) {
-        if (r == Result::OK && result.size() > 0) {
-          gotEffect = true;
-          effectUuid = result[0].uuid;
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_TRUE(gotEffect);
-  Result retval = Result::NOT_INITIALIZED;
-  sp<IEffect> effect;
-  ret = effectsFactory->createEffect(
-      effectUuid, 1 /*session*/, 1 /*ioHandle*/,
-      [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
-        retval = r;
-        if (r == Result::OK) {
-          effect = result;
-        }
-      });
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  EXPECT_NE(nullptr, effect.get());
-}
-
-TEST_F(AudioEffectsFactoryHidlTest, GetDescriptor) {
-  description(
-      "Verify that effects factory can provide an effect descriptor via "
-      "GetDescriptor");
-  hidl_vec<EffectDescriptor> allDescriptors;
-  Return<void> ret = effectsFactory->getAllDescriptors(
-      [&](Result r, const hidl_vec<EffectDescriptor>& result) {
-        if (r == Result::OK) {
-          allDescriptors = result;
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_GT(allDescriptors.size(), 0u);
-  for (size_t i = 0; i < allDescriptors.size(); ++i) {
-    ret = effectsFactory->getDescriptor(
-        allDescriptors[i].uuid, [&](Result r, const EffectDescriptor& result) {
-          EXPECT_EQ(r, Result::OK);
-          EXPECT_EQ(result, allDescriptors[i]);
-        });
-  }
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectsFactoryHidlTest, DebugDumpInvalidArgument) {
-    description("Verify that debugDump doesn't crash on invalid arguments");
-    Return<void> ret = effectsFactory->debugDump(hidl_handle());
-    ASSERT_TRUE(ret.isOk());
-}
-
-// Equalizer effect is required by CDD, but only the type is fixed.
-// This is the same UUID as AudioEffect.EFFECT_TYPE_EQUALIZER in Java.
-static const Uuid EQUALIZER_EFFECT_TYPE = {
-    0x0bed4300, 0xddd6, 0x11db, 0x8f34,
-    std::array<uint8_t, 6>{{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}};
-// Loudness Enhancer effect is required by CDD, but only the type is fixed.
-// This is the same UUID as AudioEffect.EFFECT_TYPE_LOUDNESS_ENHANCER in Java.
-static const Uuid LOUDNESS_ENHANCER_EFFECT_TYPE = {
-    0xfe3199be, 0xaed0, 0x413f, 0x87bb,
-    std::array<uint8_t, 6>{{0x11, 0x26, 0x0e, 0xb6, 0x3c, 0xf1}}};
-
-// The main test class for Audio Effect HIDL HAL.
-class AudioEffectHidlTest : public ::testing::VtsHalHidlTargetTestBase {
- public:
-  void SetUp() override {
-    effectsFactory =
-        ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>();
-    ASSERT_NE(nullptr, effectsFactory.get());
-
-    findAndCreateEffect(getEffectType());
-    ASSERT_NE(nullptr, effect.get());
-
-    Return<Result> ret = effect->init();
-    ASSERT_TRUE(ret.isOk());
-    ASSERT_EQ(Result::OK, ret);
-  }
-
-  void TearDown() override {
-    effect.clear();
-    effectsFactory.clear();
-  }
-
- protected:
-  static void description(const std::string& description) {
-    RecordProperty("description", description);
-  }
-
-  virtual Uuid getEffectType() { return EQUALIZER_EFFECT_TYPE; }
-
-  void findAndCreateEffect(const Uuid& type);
-  void findEffectInstance(const Uuid& type, Uuid* uuid);
-  void getChannelCount(uint32_t* channelCount);
-
-  sp<IEffectsFactory> effectsFactory;
-  sp<IEffect> effect;
-};
-
-void AudioEffectHidlTest::findAndCreateEffect(const Uuid& type) {
-  Uuid effectUuid;
-  findEffectInstance(type, &effectUuid);
-  Return<void> ret = effectsFactory->createEffect(
-      effectUuid, 1 /*session*/, 1 /*ioHandle*/,
-      [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
-        if (r == Result::OK) {
-          effect = result;
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-}
-
-void AudioEffectHidlTest::findEffectInstance(const Uuid& type, Uuid* uuid) {
-  bool effectFound = false;
-  Return<void> ret = effectsFactory->getAllDescriptors(
-      [&](Result r, const hidl_vec<EffectDescriptor>& result) {
-        if (r == Result::OK) {
-          for (const auto& desc : result) {
-            if (desc.type == type) {
-              effectFound = true;
-              *uuid = desc.uuid;
-              break;
-            }
-          }
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_TRUE(effectFound);
-}
-
-void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) {
-  Result retval;
-  EffectConfig currentConfig;
-  Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
-    retval = r;
-    if (r == Result::OK) {
-      currentConfig = conf;
-    }
-  });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-  ASSERT_TRUE(audio_channel_mask_is_valid(
-      static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels)));
-  *channelCount = audio_channel_count_from_out_mask(
-      static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels));
-}
-
-TEST_F(AudioEffectHidlTest, Close) {
-  description("Verify that an effect can be closed");
-  Return<Result> ret = effect->close();
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-}
-
-TEST_F(AudioEffectHidlTest, GetDescriptor) {
-  description(
-      "Verify that an effect can return its own descriptor via GetDescriptor");
-  Result retval = Result::NOT_INITIALIZED;
-  Uuid actualType;
-  Return<void> ret =
-      effect->getDescriptor([&](Result r, const EffectDescriptor& desc) {
-        retval = r;
-        if (r == Result::OK) {
-          actualType = desc.type;
-        }
-      });
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  EXPECT_EQ(getEffectType(), actualType);
-}
-
-TEST_F(AudioEffectHidlTest, GetSetConfig) {
-  description(
-      "Verify that it is possible to manipulate effect config via Get / "
-      "SetConfig");
-  Result retval = Result::NOT_INITIALIZED;
-  EffectConfig currentConfig;
-  Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
-    retval = r;
-    if (r == Result::OK) {
-      currentConfig = conf;
-    }
-  });
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  Return<Result> ret2 = effect->setConfig(currentConfig, nullptr, nullptr);
-  EXPECT_TRUE(ret2.isOk());
-  EXPECT_EQ(Result::OK, ret2);
-}
-
-TEST_F(AudioEffectHidlTest, GetConfigReverse) {
-  description("Verify that GetConfigReverse does not crash");
-  Return<void> ret =
-      effect->getConfigReverse([&](Result, const EffectConfig&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, GetSupportedAuxChannelsConfigs) {
-  description("Verify that GetSupportedAuxChannelsConfigs does not crash");
-  Return<void> ret = effect->getSupportedAuxChannelsConfigs(
-      0, [&](Result, const hidl_vec<EffectAuxChannelsConfig>&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, GetAuxChannelsConfig) {
-  description("Verify that GetAuxChannelsConfig does not crash");
-  Return<void> ret = effect->getAuxChannelsConfig(
-      [&](Result, const EffectAuxChannelsConfig&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, SetAuxChannelsConfig) {
-  description("Verify that SetAuxChannelsConfig does not crash");
-  Return<Result> ret = effect->setAuxChannelsConfig(EffectAuxChannelsConfig());
-  EXPECT_TRUE(ret.isOk());
-}
-
-// Not generated automatically because AudioBuffer contains
-// instances of hidl_memory which can't be compared properly
-// in general case due to presence of handles.
-//
-// However, in this particular case, handles must not present
-// thus comparison is possible.
-//
-// operator== must be defined in the same namespace as the structures.
-namespace android {
-namespace hardware {
-namespace audio {
-namespace effect {
-namespace V2_0 {
-inline bool operator==(const AudioBuffer& lhs, const AudioBuffer& rhs) {
-  return lhs.id == rhs.id && lhs.frameCount == rhs.frameCount &&
-         lhs.data.handle() == nullptr && rhs.data.handle() == nullptr;
-}
-
-inline bool operator==(const EffectBufferConfig& lhs,
-                       const EffectBufferConfig& rhs) {
-  return lhs.buffer == rhs.buffer && lhs.samplingRateHz == rhs.samplingRateHz &&
-         lhs.channels == rhs.channels && lhs.format == rhs.format &&
-         lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask;
-}
-
-inline bool operator==(const EffectConfig& lhs, const EffectConfig& rhs) {
-  return lhs.inputCfg == rhs.inputCfg && lhs.outputCfg == rhs.outputCfg;
-}
-}  // namespace V2_0
-}  // namespace effect
-}  // namespace audio
-}  // namespace hardware
-}  // namespace android
-
-TEST_F(AudioEffectHidlTest, Reset) {
-  description("Verify that Reset preserves effect configuration");
-  Result retval = Result::NOT_INITIALIZED;
-  EffectConfig originalConfig;
-  Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
-    retval = r;
-    if (r == Result::OK) {
-      originalConfig = conf;
-    }
-  });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-  Return<Result> ret2 = effect->reset();
-  EXPECT_TRUE(ret2.isOk());
-  EXPECT_EQ(Result::OK, ret2);
-  EffectConfig configAfterReset;
-  ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
-    retval = r;
-    if (r == Result::OK) {
-      configAfterReset = conf;
-    }
-  });
-  EXPECT_EQ(originalConfig, configAfterReset);
-}
-
-TEST_F(AudioEffectHidlTest, DisableEnableDisable) {
-  description("Verify Disable -> Enable -> Disable sequence for an effect");
-  Return<Result> ret = effect->disable();
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::INVALID_ARGUMENTS, ret);
-  ret = effect->enable();
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-  ret = effect->disable();
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-}
-
-TEST_F(AudioEffectHidlTest, SetDevice) {
-  description("Verify that SetDevice works for an output chain effect");
-  Return<Result> ret = effect->setDevice(AudioDevice::OUT_SPEAKER);
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-}
-
-TEST_F(AudioEffectHidlTest, SetAndGetVolume) {
-  description("Verify that SetAndGetVolume method works for an effect");
-  uint32_t channelCount;
-  getChannelCount(&channelCount);
-  hidl_vec<uint32_t> volumes;
-  volumes.resize(channelCount);
-  for (uint32_t i = 0; i < channelCount; ++i) {
-    volumes[i] = 0;
-  }
-  Result retval = Result::NOT_INITIALIZED;
-  Return<void> ret = effect->setAndGetVolume(
-      volumes, [&](Result r, const hidl_vec<uint32_t>&) { retval = r; });
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, retval);
-}
-
-TEST_F(AudioEffectHidlTest, VolumeChangeNotification) {
-  description("Verify that effect accepts VolumeChangeNotification");
-  uint32_t channelCount;
-  getChannelCount(&channelCount);
-  hidl_vec<uint32_t> volumes;
-  volumes.resize(channelCount);
-  for (uint32_t i = 0; i < channelCount; ++i) {
-    volumes[i] = 0;
-  }
-  Return<Result> ret = effect->volumeChangeNotification(volumes);
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-}
-
-TEST_F(AudioEffectHidlTest, SetAudioMode) {
-  description("Verify that SetAudioMode works for an effect");
-  Return<Result> ret = effect->setAudioMode(AudioMode::NORMAL);
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-}
-
-TEST_F(AudioEffectHidlTest, SetConfigReverse) {
-  description("Verify that SetConfigReverse does not crash");
-  Return<Result> ret =
-      effect->setConfigReverse(EffectConfig(), nullptr, nullptr);
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, SetInputDevice) {
-  description("Verify that SetInputDevice does not crash");
-  Return<Result> ret = effect->setInputDevice(AudioDevice::IN_BUILTIN_MIC);
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, SetAudioSource) {
-  description("Verify that SetAudioSource does not crash");
-  Return<Result> ret = effect->setAudioSource(AudioSource::MIC);
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, Offload) {
-  description("Verify that calling Offload method does not crash");
-  EffectOffloadParameter offloadParam;
-  offloadParam.isOffload = false;
-  offloadParam.ioHandle =
-      static_cast<int>(AudioHandleConsts::AUDIO_IO_HANDLE_NONE);
-  Return<Result> ret = effect->offload(offloadParam);
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, PrepareForProcessing) {
-  description("Verify that PrepareForProcessing method works for an effect");
-  Result retval = Result::NOT_INITIALIZED;
-  Return<void> ret = effect->prepareForProcessing(
-      [&](Result r, const MQDescriptorSync<Result>&) { retval = r; });
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, retval);
-}
-
-TEST_F(AudioEffectHidlTest, SetProcessBuffers) {
-  description("Verify that SetProcessBuffers works for an effect");
-  sp<IAllocator> ashmem = IAllocator::getService("ashmem");
-  ASSERT_NE(nullptr, ashmem.get());
-  bool success = false;
-  AudioBuffer buffer;
-  Return<void> ret =
-      ashmem->allocate(1024, [&](bool s, const hidl_memory& memory) {
-        success = s;
-        if (s) {
-          buffer.data = memory;
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_TRUE(success);
-  Return<Result> ret2 = effect->setProcessBuffers(buffer, buffer);
-  EXPECT_TRUE(ret2.isOk());
-  EXPECT_EQ(Result::OK, ret2);
-}
-
-TEST_F(AudioEffectHidlTest, Command) {
-  description("Verify that Command does not crash");
-  Return<void> ret = effect->command(0, hidl_vec<uint8_t>(), 0,
-                                     [&](int32_t, const hidl_vec<uint8_t>&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, SetParameter) {
-  description("Verify that SetParameter does not crash");
-  Return<Result> ret =
-      effect->setParameter(hidl_vec<uint8_t>(), hidl_vec<uint8_t>());
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, GetParameter) {
-  description("Verify that GetParameter does not crash");
-  Return<void> ret = effect->getParameter(
-      hidl_vec<uint8_t>(), 0, [&](Result, const hidl_vec<uint8_t>&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, GetSupportedConfigsForFeature) {
-  description("Verify that GetSupportedConfigsForFeature does not crash");
-  Return<void> ret = effect->getSupportedConfigsForFeature(
-      0, 0, 0, [&](Result, uint32_t, const hidl_vec<uint8_t>&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, GetCurrentConfigForFeature) {
-  description("Verify that GetCurrentConfigForFeature does not crash");
-  Return<void> ret = effect->getCurrentConfigForFeature(
-      0, 0, [&](Result, const hidl_vec<uint8_t>&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, SetCurrentConfigForFeature) {
-  description("Verify that SetCurrentConfigForFeature does not crash");
-  Return<Result> ret =
-      effect->setCurrentConfigForFeature(0, hidl_vec<uint8_t>());
-  EXPECT_TRUE(ret.isOk());
-}
-
-
-// The main test class for Equalizer Audio Effect HIDL HAL.
-class EqualizerAudioEffectHidlTest : public AudioEffectHidlTest {
- public:
-  void SetUp() override {
-    AudioEffectHidlTest::SetUp();
-    equalizer = IEqualizerEffect::castFrom(effect);
-    ASSERT_NE(nullptr, equalizer.get());
-  }
-
- protected:
-  Uuid getEffectType() override { return EQUALIZER_EFFECT_TYPE; }
-  void getNumBands(uint16_t* numBands);
-  void getLevelRange(int16_t* minLevel, int16_t* maxLevel);
-  void getBandFrequencyRange(uint16_t band, uint32_t* minFreq,
-                             uint32_t* centerFreq, uint32_t* maxFreq);
-  void getPresetCount(size_t* count);
-
-  sp<IEqualizerEffect> equalizer;
-};
-
-void EqualizerAudioEffectHidlTest::getNumBands(uint16_t* numBands) {
-  Result retval = Result::NOT_INITIALIZED;
-  Return<void> ret = equalizer->getNumBands([&](Result r, uint16_t b) {
-    retval = r;
-    if (retval == Result::OK) {
-      *numBands = b;
-    }
-  });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-}
-
-void EqualizerAudioEffectHidlTest::getLevelRange(int16_t* minLevel,
-                                                 int16_t* maxLevel) {
-  Result retval = Result::NOT_INITIALIZED;
-  Return<void> ret =
-      equalizer->getLevelRange([&](Result r, int16_t min, int16_t max) {
-        retval = r;
-        if (retval == Result::OK) {
-          *minLevel = min;
-          *maxLevel = max;
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-}
-
-void EqualizerAudioEffectHidlTest::getBandFrequencyRange(uint16_t band,
-                                                         uint32_t* minFreq,
-                                                         uint32_t* centerFreq,
-                                                         uint32_t* maxFreq) {
-  Result retval = Result::NOT_INITIALIZED;
-  Return<void> ret = equalizer->getBandFrequencyRange(
-      band, [&](Result r, uint32_t min, uint32_t max) {
-        retval = r;
-        if (retval == Result::OK) {
-          *minFreq = min;
-          *maxFreq = max;
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-  ret = equalizer->getBandCenterFrequency(band, [&](Result r, uint32_t center) {
-    retval = r;
-    if (retval == Result::OK) {
-      *centerFreq = center;
-    }
-  });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-}
-
-void EqualizerAudioEffectHidlTest::getPresetCount(size_t* count) {
-  Result retval = Result::NOT_INITIALIZED;
-  Return<void> ret = equalizer->getPresetNames(
-      [&](Result r, const hidl_vec<hidl_string>& names) {
-        retval = r;
-        if (retval == Result::OK) {
-          *count = names.size();
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetNumBands) {
-  description("Verify that Equalizer effect reports at least one band");
-  uint16_t numBands = 0;
-  getNumBands(&numBands);
-  EXPECT_GT(numBands, 0);
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetLevelRange) {
-  description("Verify that Equalizer effect reports adequate band level range");
-  int16_t minLevel = 0x7fff, maxLevel = 0;
-  getLevelRange(&minLevel, &maxLevel);
-  EXPECT_GT(maxLevel, minLevel);
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetSetBandLevel) {
-  description(
-      "Verify that manipulating band levels works for Equalizer effect");
-  uint16_t numBands = 0;
-  getNumBands(&numBands);
-  ASSERT_GT(numBands, 0);
-  int16_t levels[3]{0x7fff, 0, 0};
-  getLevelRange(&levels[0], &levels[2]);
-  ASSERT_GT(levels[2], levels[0]);
-  levels[1] = (levels[2] + levels[0]) / 2;
-  for (uint16_t i = 0; i < numBands; ++i) {
-    for (size_t j = 0; j < ARRAY_SIZE(levels); ++j) {
-      Return<Result> ret = equalizer->setBandLevel(i, levels[j]);
-      EXPECT_TRUE(ret.isOk());
-      EXPECT_EQ(Result::OK, ret);
-      Result retval = Result::NOT_INITIALIZED;
-      int16_t actualLevel;
-      Return<void> ret2 = equalizer->getBandLevel(i, [&](Result r, int16_t l) {
-        retval = r;
-        if (retval == Result::OK) {
-          actualLevel = l;
-        }
-      });
-      EXPECT_TRUE(ret2.isOk());
-      EXPECT_EQ(Result::OK, retval);
-      EXPECT_EQ(levels[j], actualLevel);
-    }
-  }
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetBandCenterFrequencyAndRange) {
-  description(
-      "Verify that Equalizer effect reports adequate band frequency range");
-  uint16_t numBands = 0;
-  getNumBands(&numBands);
-  ASSERT_GT(numBands, 0);
-  for (uint16_t i = 0; i < numBands; ++i) {
-    uint32_t minFreq = 0xffffffff, centerFreq = 0xffffffff,
-             maxFreq = 0xffffffff;
-    getBandFrequencyRange(i, &minFreq, &centerFreq, &maxFreq);
-    // Note: NXP legacy implementation reports "1" as upper bound for last band,
-    // so this check fails.
-    EXPECT_GE(maxFreq, centerFreq);
-    EXPECT_GE(centerFreq, minFreq);
-  }
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetBandForFrequency) {
-  description(
-      "Verify that Equalizer effect supports GetBandForFrequency correctly");
-  uint16_t numBands = 0;
-  getNumBands(&numBands);
-  ASSERT_GT(numBands, 0);
-  for (uint16_t i = 0; i < numBands; ++i) {
-    uint32_t freqs[3]{0, 0, 0};
-    getBandFrequencyRange(i, &freqs[0], &freqs[1], &freqs[2]);
-    // NXP legacy implementation reports "1" as upper bound for last band, some
-    // of the checks fail.
-    for (size_t j = 0; j < ARRAY_SIZE(freqs); ++j) {
-      if (j == 0) {
-        freqs[j]++;
-      }  // Min frequency is an open interval.
-      Result retval = Result::NOT_INITIALIZED;
-      uint16_t actualBand = numBands + 1;
-      Return<void> ret =
-          equalizer->getBandForFrequency(freqs[j], [&](Result r, uint16_t b) {
-            retval = r;
-            if (retval == Result::OK) {
-              actualBand = b;
-            }
-          });
-      EXPECT_TRUE(ret.isOk());
-      EXPECT_EQ(Result::OK, retval);
-      EXPECT_EQ(i, actualBand) << "Frequency: " << freqs[j];
-    }
-  }
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetPresetNames) {
-  description("Verify that Equalizer effect reports at least one preset");
-  size_t presetCount;
-  getPresetCount(&presetCount);
-  EXPECT_GT(presetCount, 0u);
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetSetCurrentPreset) {
-  description(
-      "Verify that manipulating the current preset for Equalizer effect");
-  size_t presetCount;
-  getPresetCount(&presetCount);
-  ASSERT_GT(presetCount, 0u);
-  for (uint16_t i = 0; i < presetCount; ++i) {
-    Return<Result> ret = equalizer->setCurrentPreset(i);
-    EXPECT_TRUE(ret.isOk());
-    EXPECT_EQ(Result::OK, ret);
-    Result retval = Result::NOT_INITIALIZED;
-    uint16_t actualPreset = 0xffff;
-    Return<void> ret2 = equalizer->getCurrentPreset([&](Result r, uint16_t p) {
-      retval = r;
-      if (retval == Result::OK) {
-        actualPreset = p;
-      }
-    });
-    EXPECT_TRUE(ret2.isOk());
-    EXPECT_EQ(Result::OK, retval);
-    EXPECT_EQ(i, actualPreset);
-  }
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetSetAllProperties) {
-  description(
-      "Verify that setting band levels and presets works via Get / "
-      "SetAllProperties for Equalizer effect");
-  using AllProperties =
-      android::hardware::audio::effect::V2_0::IEqualizerEffect::AllProperties;
-  uint16_t numBands = 0;
-  getNumBands(&numBands);
-  ASSERT_GT(numBands, 0);
-  AllProperties props;
-  props.bandLevels.resize(numBands);
-  for (size_t i = 0; i < numBands; ++i) {
-    props.bandLevels[i] = 0;
-  }
-
-  AllProperties actualProps;
-  Result retval = Result::NOT_INITIALIZED;
-
-  // Verify setting of the band levels via properties.
-  props.curPreset = -1;
-  Return<Result> ret = equalizer->setAllProperties(props);
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-  Return<void> ret2 =
-      equalizer->getAllProperties([&](Result r, AllProperties p) {
-        retval = r;
-        if (retval == Result::OK) {
-          actualProps = p;
-        }
-      });
-  EXPECT_TRUE(ret2.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  EXPECT_EQ(props.bandLevels, actualProps.bandLevels);
-
-  // Verify setting of the current preset via properties.
-  props.curPreset = 0;  // Assuming there is at least one preset.
-  ret = equalizer->setAllProperties(props);
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-  ret2 = equalizer->getAllProperties([&](Result r, AllProperties p) {
-    retval = r;
-    if (retval == Result::OK) {
-      actualProps = p;
-    }
-  });
-  EXPECT_TRUE(ret2.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  EXPECT_EQ(props.curPreset, actualProps.curPreset);
-}
-
-// The main test class for Equalizer Audio Effect HIDL HAL.
-class LoudnessEnhancerAudioEffectHidlTest : public AudioEffectHidlTest {
- public:
-  void SetUp() override {
-    AudioEffectHidlTest::SetUp();
-    enhancer = ILoudnessEnhancerEffect::castFrom(effect);
-    ASSERT_NE(nullptr, enhancer.get());
-  }
-
- protected:
-  Uuid getEffectType() override { return LOUDNESS_ENHANCER_EFFECT_TYPE; }
-
-  sp<ILoudnessEnhancerEffect> enhancer;
-};
-
-TEST_F(LoudnessEnhancerAudioEffectHidlTest, GetSetTargetGain) {
-  description(
-      "Verify that manipulating the target gain works for Loudness Enhancer "
-      "effect");
-  const int32_t gain = 100;
-  Return<Result> ret = enhancer->setTargetGain(gain);
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-  int32_t actualGain = 0;
-  Result retval;
-  Return<void> ret2 = enhancer->getTargetGain([&](Result r, int32_t g) {
-    retval = r;
-    if (retval == Result::OK) {
-      actualGain = g;
-    }
-  });
-  EXPECT_TRUE(ret2.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  EXPECT_EQ(gain, actualGain);
-}
-
-int main(int argc, char** argv) {
-    ::testing::AddGlobalTestEnvironment(AudioEffectsFactoryHidlEnvironment::Instance());
-    ::testing::InitGoogleTest(&argc, argv);
-    AudioEffectsFactoryHidlEnvironment::Instance()->init(&argc, argv);
-    int status = RUN_ALL_TESTS();
-    LOG(INFO) << "Test result = " << status;
-    return status;
-}
diff --git a/audio/effect/2.0/xml/audio_effects_conf_V2_0.xsd b/audio/effect/2.0/xml/audio_effects_conf.xsd
similarity index 100%
rename from audio/effect/2.0/xml/audio_effects_conf_V2_0.xsd
rename to audio/effect/2.0/xml/audio_effects_conf.xsd
diff --git a/audio/effect/4.0/default/AcousticEchoCancelerEffect.cpp b/audio/effect/4.0/default/AcousticEchoCancelerEffect.cpp
deleted file mode 100644
index 242740e..0000000
--- a/audio/effect/4.0/default/AcousticEchoCancelerEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2018 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 "AEC_Effect_HAL"
-
-#include "AcousticEchoCancelerEffect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/AcousticEchoCancelerEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/AcousticEchoCancelerEffect.h b/audio/effect/4.0/default/AcousticEchoCancelerEffect.h
deleted file mode 100644
index 0ac0a1e..0000000
--- a/audio/effect/4.0/default/AcousticEchoCancelerEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ACOUSTICECHOCANCELEREFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ACOUSTICECHOCANCELEREFFECT_H
-
-#include <android/hardware/audio/effect/4.0/IAcousticEchoCancelerEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/AcousticEchoCancelerEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ACOUSTICECHOCANCELEREFFECT_H
diff --git a/audio/effect/4.0/default/Android.bp b/audio/effect/4.0/default/Android.bp
deleted file mode 100644
index dcb2269..0000000
--- a/audio/effect/4.0/default/Android.bp
+++ /dev/null
@@ -1,50 +0,0 @@
-cc_library_shared {
-    name: "android.hardware.audio.effect@4.0-impl",
-    defaults: ["hidl_defaults"],
-    vendor: true,
-    relative_install_path: "hw",
-    srcs: [
-        "AcousticEchoCancelerEffect.cpp",
-        "AudioBufferManager.cpp",
-        "AutomaticGainControlEffect.cpp",
-        "BassBoostEffect.cpp",
-        "Conversions.cpp",
-        "DownmixEffect.cpp",
-        "Effect.cpp",
-        "EffectsFactory.cpp",
-        "EnvironmentalReverbEffect.cpp",
-        "EqualizerEffect.cpp",
-        "LoudnessEnhancerEffect.cpp",
-        "NoiseSuppressionEffect.cpp",
-        "PresetReverbEffect.cpp",
-        "VirtualizerEffect.cpp",
-        "VisualizerEffect.cpp",
-    ],
-
-    shared_libs: [
-        "libbase",
-        "libcutils",
-        "libeffects",
-        "libfmq",
-        "libhidlbase",
-        "libhidlmemory",
-        "libhidltransport",
-        "liblog",
-        "libutils",
-        "android.hardware.audio.common-util",
-        "android.hardware.audio.common@4.0",
-        "android.hardware.audio.common@4.0-util",
-        "android.hardware.audio.effect@4.0",
-        "android.hidl.memory@1.0",
-    ],
-
-    header_libs: [
-        "android.hardware.audio.common.util@all-versions",
-        "android.hardware.audio.effect@all-versions-impl",
-        "libaudio_system_headers",
-        "libaudioclient_headers",
-        "libeffects_headers",
-        "libhardware_headers",
-        "libmedia_headers",
-    ],
-}
diff --git a/audio/effect/4.0/default/AudioBufferManager.cpp b/audio/effect/4.0/default/AudioBufferManager.cpp
deleted file mode 100644
index 2d75f3f..0000000
--- a/audio/effect/4.0/default/AudioBufferManager.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2018 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 "AudioBufferManager.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/AudioBufferManager.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/AudioBufferManager.h b/audio/effect/4.0/default/AudioBufferManager.h
deleted file mode 100644
index 1f151e6..0000000
--- a/audio/effect/4.0/default/AudioBufferManager.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUDIO_BUFFER_MANAGER_H_
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUDIO_BUFFER_MANAGER_H_
-
-#include <android/hardware/audio/effect/4.0/types.h>
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/AudioBufferManager.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUDIO_BUFFER_MANAGER_H_
diff --git a/audio/effect/4.0/default/AutomaticGainControlEffect.cpp b/audio/effect/4.0/default/AutomaticGainControlEffect.cpp
deleted file mode 100644
index 9d21c8a..0000000
--- a/audio/effect/4.0/default/AutomaticGainControlEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2018 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 "AGC_Effect_HAL"
-
-#include "AutomaticGainControlEffect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/AutomaticGainControlEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/AutomaticGainControlEffect.h b/audio/effect/4.0/default/AutomaticGainControlEffect.h
deleted file mode 100644
index 7f12007..0000000
--- a/audio/effect/4.0/default/AutomaticGainControlEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUTOMATICGAINCONTROLEFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUTOMATICGAINCONTROLEFFECT_H
-
-#include <android/hardware/audio/effect/4.0/IAutomaticGainControlEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/AutomaticGainControlEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUTOMATICGAINCONTROLEFFECT_H
diff --git a/audio/effect/4.0/default/BassBoostEffect.cpp b/audio/effect/4.0/default/BassBoostEffect.cpp
deleted file mode 100644
index 74a626b..0000000
--- a/audio/effect/4.0/default/BassBoostEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2018 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 "BassBoost_HAL"
-
-#include "BassBoostEffect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/BassBoostEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/BassBoostEffect.h b/audio/effect/4.0/default/BassBoostEffect.h
deleted file mode 100644
index 206a75f..0000000
--- a/audio/effect/4.0/default/BassBoostEffect.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_BASSBOOSTEFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_BASSBOOSTEFFECT_H
-
-#include <android/hardware/audio/effect/4.0/IBassBoostEffect.h>
-
-#include <hidl/MQDescriptor.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/BassBoostEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_BASSBOOSTEFFECT_H
diff --git a/audio/effect/4.0/default/Conversions.cpp b/audio/effect/4.0/default/Conversions.cpp
deleted file mode 100644
index 91285ae..0000000
--- a/audio/effect/4.0/default/Conversions.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2018 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 "Conversions.h"
-#include "HidlUtils.h"
-
-using ::android::hardware::audio::common::V4_0::HidlUtils;
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/Conversions.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/Conversions.h b/audio/effect/4.0/default/Conversions.h
deleted file mode 100644
index 50e380f..0000000
--- a/audio/effect/4.0/default/Conversions.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_CONVERSIONS_H_
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_CONVERSIONS_H_
-
-#include <android/hardware/audio/effect/4.0/types.h>
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/Conversions.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_CONVERSIONS_H_
diff --git a/audio/effect/4.0/default/DownmixEffect.cpp b/audio/effect/4.0/default/DownmixEffect.cpp
deleted file mode 100644
index 07fcab2..0000000
--- a/audio/effect/4.0/default/DownmixEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2018 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 "Downmix_HAL"
-
-#include "DownmixEffect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/DownmixEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/DownmixEffect.h b/audio/effect/4.0/default/DownmixEffect.h
deleted file mode 100644
index 5ae820b..0000000
--- a/audio/effect/4.0/default/DownmixEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_DOWNMIXEFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_DOWNMIXEFFECT_H
-
-#include <android/hardware/audio/effect/4.0/IDownmixEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/DownmixEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_DOWNMIXEFFECT_H
diff --git a/audio/effect/4.0/default/Effect.cpp b/audio/effect/4.0/default/Effect.cpp
deleted file mode 100644
index 707044b..0000000
--- a/audio/effect/4.0/default/Effect.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 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 <memory.h>
-
-#define LOG_TAG "EffectHAL"
-#define ATRACE_TAG ATRACE_TAG_AUDIO
-
-#include "Conversions.h"
-#include "Effect.h"
-#include "common/all-versions/default/EffectMap.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/Effect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/Effect.h b/audio/effect/4.0/default/Effect.h
deleted file mode 100644
index 9ca79c4..0000000
--- a/audio/effect/4.0/default/Effect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECT_H
-
-#include <android/hardware/audio/effect/4.0/IEffect.h>
-
-#include "AudioBufferManager.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/Effect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECT_H
diff --git a/audio/effect/4.0/default/EffectsFactory.cpp b/audio/effect/4.0/default/EffectsFactory.cpp
deleted file mode 100644
index ee0413d..0000000
--- a/audio/effect/4.0/default/EffectsFactory.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2018 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 "EffectFactoryHAL"
-#include "EffectsFactory.h"
-#include "AcousticEchoCancelerEffect.h"
-#include "AutomaticGainControlEffect.h"
-#include "BassBoostEffect.h"
-#include "Conversions.h"
-#include "DownmixEffect.h"
-#include "Effect.h"
-#include "EnvironmentalReverbEffect.h"
-#include "EqualizerEffect.h"
-#include "HidlUtils.h"
-#include "LoudnessEnhancerEffect.h"
-#include "NoiseSuppressionEffect.h"
-#include "PresetReverbEffect.h"
-#include "VirtualizerEffect.h"
-#include "VisualizerEffect.h"
-#include "common/all-versions/default/EffectMap.h"
-
-using ::android::hardware::audio::common::V4_0::HidlUtils;
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/EffectsFactory.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/EffectsFactory.h b/audio/effect/4.0/default/EffectsFactory.h
deleted file mode 100644
index 48e4b4c..0000000
--- a/audio/effect/4.0/default/EffectsFactory.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECTSFACTORY_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECTSFACTORY_H
-
-#include <system/audio_effect.h>
-
-#include <android/hardware/audio/effect/4.0/IEffectsFactory.h>
-
-#include <hidl/MQDescriptor.h>
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/EffectsFactory.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECTSFACTORY_H
diff --git a/audio/effect/4.0/default/EnvironmentalReverbEffect.cpp b/audio/effect/4.0/default/EnvironmentalReverbEffect.cpp
deleted file mode 100644
index cc3102d..0000000
--- a/audio/effect/4.0/default/EnvironmentalReverbEffect.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2018 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 "EnvReverb_HAL"
-#include <android/log.h>
-
-#include "EnvironmentalReverbEffect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/EnvironmentalReverbEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/EnvironmentalReverbEffect.h b/audio/effect/4.0/default/EnvironmentalReverbEffect.h
deleted file mode 100644
index c0fb25c..0000000
--- a/audio/effect/4.0/default/EnvironmentalReverbEffect.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ENVIRONMENTALREVERBEFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ENVIRONMENTALREVERBEFFECT_H
-
-#include <system/audio_effects/effect_environmentalreverb.h>
-
-#include <android/hardware/audio/effect/4.0/IEnvironmentalReverbEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/EnvironmentalReverbEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ENVIRONMENTALREVERBEFFECT_H
diff --git a/audio/effect/4.0/default/EqualizerEffect.cpp b/audio/effect/4.0/default/EqualizerEffect.cpp
deleted file mode 100644
index d0a40bc..0000000
--- a/audio/effect/4.0/default/EqualizerEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2018 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 "Equalizer_HAL"
-
-#include "EqualizerEffect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/EqualizerEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/EqualizerEffect.h b/audio/effect/4.0/default/EqualizerEffect.h
deleted file mode 100644
index 7c9463b..0000000
--- a/audio/effect/4.0/default/EqualizerEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EQUALIZEREFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EQUALIZEREFFECT_H
-
-#include <android/hardware/audio/effect/4.0/IEqualizerEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/EqualizerEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EQUALIZEREFFECT_H
diff --git a/audio/effect/4.0/default/LoudnessEnhancerEffect.cpp b/audio/effect/4.0/default/LoudnessEnhancerEffect.cpp
deleted file mode 100644
index e3c5184..0000000
--- a/audio/effect/4.0/default/LoudnessEnhancerEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2018 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 "LoudnessEnhancer_HAL"
-
-#include "LoudnessEnhancerEffect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/LoudnessEnhancerEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/LoudnessEnhancerEffect.h b/audio/effect/4.0/default/LoudnessEnhancerEffect.h
deleted file mode 100644
index 64fa26a..0000000
--- a/audio/effect/4.0/default/LoudnessEnhancerEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_LOUDNESSENHANCEREFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_LOUDNESSENHANCEREFFECT_H
-
-#include <android/hardware/audio/effect/4.0/ILoudnessEnhancerEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/LoudnessEnhancerEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_LOUDNESSENHANCEREFFECT_H
diff --git a/audio/effect/4.0/default/NoiseSuppressionEffect.h b/audio/effect/4.0/default/NoiseSuppressionEffect.h
deleted file mode 100644
index 36d45af..0000000
--- a/audio/effect/4.0/default/NoiseSuppressionEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_NOISESUPPRESSIONEFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_NOISESUPPRESSIONEFFECT_H
-
-#include <android/hardware/audio/effect/4.0/INoiseSuppressionEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/NoiseSuppressionEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_NOISESUPPRESSIONEFFECT_H
diff --git a/audio/effect/4.0/default/OWNERS b/audio/effect/4.0/default/OWNERS
deleted file mode 100644
index 6fdc97c..0000000
--- a/audio/effect/4.0/default/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-elaurent@google.com
-krocard@google.com
-mnaganov@google.com
diff --git a/audio/effect/4.0/default/PresetReverbEffect.cpp b/audio/effect/4.0/default/PresetReverbEffect.cpp
deleted file mode 100644
index 0c23be7..0000000
--- a/audio/effect/4.0/default/PresetReverbEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2018 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 "PresetReverb_HAL"
-
-#include "PresetReverbEffect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/PresetReverbEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/PresetReverbEffect.h b/audio/effect/4.0/default/PresetReverbEffect.h
deleted file mode 100644
index 3eeae0a..0000000
--- a/audio/effect/4.0/default/PresetReverbEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_PRESETREVERBEFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_PRESETREVERBEFFECT_H
-
-#include <android/hardware/audio/effect/4.0/IPresetReverbEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/PresetReverbEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_PRESETREVERBEFFECT_H
diff --git a/audio/effect/4.0/default/VirtualizerEffect.cpp b/audio/effect/4.0/default/VirtualizerEffect.cpp
deleted file mode 100644
index f50e8ad..0000000
--- a/audio/effect/4.0/default/VirtualizerEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2018 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 "Virtualizer_HAL"
-
-#include "VirtualizerEffect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/VirtualizerEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/VirtualizerEffect.h b/audio/effect/4.0/default/VirtualizerEffect.h
deleted file mode 100644
index 8e7114e..0000000
--- a/audio/effect/4.0/default/VirtualizerEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VIRTUALIZEREFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VIRTUALIZEREFFECT_H
-
-#include <android/hardware/audio/effect/4.0/IVirtualizerEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/VirtualizerEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VIRTUALIZEREFFECT_H
diff --git a/audio/effect/4.0/default/VisualizerEffect.cpp b/audio/effect/4.0/default/VisualizerEffect.cpp
deleted file mode 100644
index 8d4f100..0000000
--- a/audio/effect/4.0/default/VisualizerEffect.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2018 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 "Visualizer_HAL"
-
-#include "VisualizerEffect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/VisualizerEffect.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/effect/4.0/default/VisualizerEffect.h b/audio/effect/4.0/default/VisualizerEffect.h
deleted file mode 100644
index 6b5ab9c..0000000
--- a/audio/effect/4.0/default/VisualizerEffect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VISUALIZEREFFECT_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VISUALIZEREFFECT_H
-
-#include <android/hardware/audio/effect/4.0/IVisualizerEffect.h>
-
-#include "Effect.h"
-
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/VisualizerEffect.h>
-#undef AUDIO_HAL_VERSION
-
-#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VISUALIZEREFFECT_H
diff --git a/audio/effect/4.0/vts/OWNERS b/audio/effect/4.0/vts/OWNERS
deleted file mode 100644
index 8711a9f..0000000
--- a/audio/effect/4.0/vts/OWNERS
+++ /dev/null
@@ -1,5 +0,0 @@
-elaurent@google.com
-krocard@google.com
-mnaganov@google.com
-yim@google.com
-zhuoyao@google.com
\ No newline at end of file
diff --git a/audio/effect/4.0/vts/functional/Android.bp b/audio/effect/4.0/vts/functional/Android.bp
deleted file mode 100644
index 96ded69..0000000
--- a/audio/effect/4.0/vts/functional/Android.bp
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// 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.
-//
-
-cc_test {
-    name: "VtsHalAudioEffectV4_0TargetTest",
-    defaults: ["VtsHalTargetTestDefaults"],
-    srcs: [
-        "VtsHalAudioEffectV4_0TargetTest.cpp",
-        "ValidateAudioEffectsConfiguration.cpp"
-    ],
-    static_libs: [
-        "android.hardware.audio.common.test.utility",
-        "android.hardware.audio.common@4.0",
-        "android.hardware.audio.effect@4.0",
-        "android.hidl.allocator@1.0",
-        "android.hidl.memory@1.0",
-        "libeffectsconfig",
-        "libicuuc",
-        "libicuuc_stubdata",
-        "libxml2",
-    ],
-    header_libs: [
-        "android.hardware.audio.common.util@all-versions",
-    ],
-}
diff --git a/audio/effect/4.0/vts/functional/VtsHalAudioEffectV4_0TargetTest.cpp b/audio/effect/4.0/vts/functional/VtsHalAudioEffectV4_0TargetTest.cpp
deleted file mode 100644
index ec783c4..0000000
--- a/audio/effect/4.0/vts/functional/VtsHalAudioEffectV4_0TargetTest.cpp
+++ /dev/null
@@ -1,852 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "AudioEffectHidlHalTest"
-#include <android-base/logging.h>
-#include <system/audio.h>
-
-#include <android/hardware/audio/effect/4.0/IEffect.h>
-#include <android/hardware/audio/effect/4.0/IEffectsFactory.h>
-#include <android/hardware/audio/effect/4.0/IEqualizerEffect.h>
-#include <android/hardware/audio/effect/4.0/ILoudnessEnhancerEffect.h>
-#include <android/hardware/audio/effect/4.0/types.h>
-#include <android/hidl/allocator/1.0/IAllocator.h>
-#include <android/hidl/memory/1.0/IMemory.h>
-
-#include <common/all-versions/VersionUtils.h>
-
-#include <VtsHalHidlTargetTestBase.h>
-#include <VtsHalHidlTargetTestEnvBase.h>
-
-using android::hardware::audio::common::V4_0::AudioDevice;
-using android::hardware::audio::common::V4_0::AudioHandleConsts;
-using android::hardware::audio::common::V4_0::AudioMode;
-using android::hardware::audio::common::V4_0::AudioSource;
-using android::hardware::audio::common::V4_0::Uuid;
-using android::hardware::audio::common::utils::mkBitfield;
-using android::hardware::audio::effect::V4_0::AudioBuffer;
-using android::hardware::audio::effect::V4_0::EffectAuxChannelsConfig;
-using android::hardware::audio::effect::V4_0::EffectBufferConfig;
-using android::hardware::audio::effect::V4_0::EffectConfig;
-using android::hardware::audio::effect::V4_0::EffectDescriptor;
-using android::hardware::audio::effect::V4_0::EffectOffloadParameter;
-using android::hardware::audio::effect::V4_0::IEffect;
-using android::hardware::audio::effect::V4_0::IEffectsFactory;
-using android::hardware::audio::effect::V4_0::IEqualizerEffect;
-using android::hardware::audio::effect::V4_0::ILoudnessEnhancerEffect;
-using android::hardware::audio::effect::V4_0::Result;
-using android::hardware::MQDescriptorSync;
-using android::hardware::Return;
-using android::hardware::Void;
-using android::hardware::hidl_handle;
-using android::hardware::hidl_memory;
-using android::hardware::hidl_string;
-using android::hardware::hidl_vec;
-using android::hidl::allocator::V1_0::IAllocator;
-using android::hidl::memory::V1_0::IMemory;
-using android::sp;
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
-#endif
-
-// Test environment for Audio Effects Factory HIDL HAL.
-class AudioEffectsFactoryHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
-   public:
-    // get the test environment singleton
-    static AudioEffectsFactoryHidlEnvironment* Instance() {
-        static AudioEffectsFactoryHidlEnvironment* instance =
-            new AudioEffectsFactoryHidlEnvironment;
-        return instance;
-    }
-
-    virtual void registerTestServices() override { registerTestService<IEffectsFactory>(); }
-};
-
-// The main test class for Audio Effects Factory HIDL HAL.
-class AudioEffectsFactoryHidlTest : public ::testing::VtsHalHidlTargetTestBase {
- public:
-  void SetUp() override {
-      effectsFactory = ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>(
-          AudioEffectsFactoryHidlEnvironment::Instance()->getServiceName<IEffectsFactory>());
-      ASSERT_NE(effectsFactory, nullptr);
-  }
-
-  void TearDown() override { effectsFactory.clear(); }
-
- protected:
-  static void description(const std::string& description) {
-    RecordProperty("description", description);
-  }
-
-  sp<IEffectsFactory> effectsFactory;
-};
-
-TEST_F(AudioEffectsFactoryHidlTest, EnumerateEffects) {
-  description("Verify that EnumerateEffects returns at least one effect");
-  Result retval = Result::NOT_INITIALIZED;
-  size_t effectCount = 0;
-  Return<void> ret = effectsFactory->getAllDescriptors(
-      [&](Result r, const hidl_vec<EffectDescriptor>& result) {
-        retval = r;
-        effectCount = result.size();
-      });
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  EXPECT_GT(effectCount, 0u);
-}
-
-TEST_F(AudioEffectsFactoryHidlTest, CreateEffect) {
-  description("Verify that an effect can be created via CreateEffect");
-  bool gotEffect = false;
-  Uuid effectUuid;
-  Return<void> ret = effectsFactory->getAllDescriptors(
-      [&](Result r, const hidl_vec<EffectDescriptor>& result) {
-        if (r == Result::OK && result.size() > 0) {
-          gotEffect = true;
-          effectUuid = result[0].uuid;
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_TRUE(gotEffect);
-  Result retval = Result::NOT_INITIALIZED;
-  sp<IEffect> effect;
-  ret = effectsFactory->createEffect(
-      effectUuid, 1 /*session*/, 1 /*ioHandle*/,
-      [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
-        retval = r;
-        if (r == Result::OK) {
-          effect = result;
-        }
-      });
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  EXPECT_NE(nullptr, effect.get());
-}
-
-TEST_F(AudioEffectsFactoryHidlTest, GetDescriptor) {
-  description(
-      "Verify that effects factory can provide an effect descriptor via "
-      "GetDescriptor");
-  hidl_vec<EffectDescriptor> allDescriptors;
-  Return<void> ret = effectsFactory->getAllDescriptors(
-      [&](Result r, const hidl_vec<EffectDescriptor>& result) {
-        if (r == Result::OK) {
-          allDescriptors = result;
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_GT(allDescriptors.size(), 0u);
-  for (size_t i = 0; i < allDescriptors.size(); ++i) {
-    ret = effectsFactory->getDescriptor(
-        allDescriptors[i].uuid, [&](Result r, const EffectDescriptor& result) {
-          EXPECT_EQ(r, Result::OK);
-          EXPECT_EQ(result, allDescriptors[i]);
-        });
-  }
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectsFactoryHidlTest, DebugDumpInvalidArgument) {
-    description("Verify that debugDump doesn't crash on invalid arguments");
-    Return<void> ret = effectsFactory->debug(hidl_handle(), {});
-    ASSERT_TRUE(ret.isOk());
-}
-
-// Equalizer effect is required by CDD, but only the type is fixed.
-// This is the same UUID as AudioEffect.EFFECT_TYPE_EQUALIZER in Java.
-static const Uuid EQUALIZER_EFFECT_TYPE = {
-    0x0bed4300, 0xddd6, 0x11db, 0x8f34,
-    std::array<uint8_t, 6>{{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}};
-// Loudness Enhancer effect is required by CDD, but only the type is fixed.
-// This is the same UUID as AudioEffect.EFFECT_TYPE_LOUDNESS_ENHANCER in Java.
-static const Uuid LOUDNESS_ENHANCER_EFFECT_TYPE = {
-    0xfe3199be, 0xaed0, 0x413f, 0x87bb,
-    std::array<uint8_t, 6>{{0x11, 0x26, 0x0e, 0xb6, 0x3c, 0xf1}}};
-
-// The main test class for Audio Effect HIDL HAL.
-class AudioEffectHidlTest : public ::testing::VtsHalHidlTargetTestBase {
- public:
-  void SetUp() override {
-    effectsFactory =
-        ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>();
-    ASSERT_NE(nullptr, effectsFactory.get());
-
-    findAndCreateEffect(getEffectType());
-    ASSERT_NE(nullptr, effect.get());
-
-    Return<Result> ret = effect->init();
-    ASSERT_TRUE(ret.isOk());
-    ASSERT_EQ(Result::OK, ret);
-  }
-
-  void TearDown() override {
-    effect.clear();
-    effectsFactory.clear();
-  }
-
- protected:
-  static void description(const std::string& description) {
-    RecordProperty("description", description);
-  }
-
-  virtual Uuid getEffectType() { return EQUALIZER_EFFECT_TYPE; }
-
-  void findAndCreateEffect(const Uuid& type);
-  void findEffectInstance(const Uuid& type, Uuid* uuid);
-  void getChannelCount(uint32_t* channelCount);
-
-  sp<IEffectsFactory> effectsFactory;
-  sp<IEffect> effect;
-};
-
-void AudioEffectHidlTest::findAndCreateEffect(const Uuid& type) {
-  Uuid effectUuid;
-  findEffectInstance(type, &effectUuid);
-  Return<void> ret = effectsFactory->createEffect(
-      effectUuid, 1 /*session*/, 1 /*ioHandle*/,
-      [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
-        if (r == Result::OK) {
-          effect = result;
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-}
-
-void AudioEffectHidlTest::findEffectInstance(const Uuid& type, Uuid* uuid) {
-  bool effectFound = false;
-  Return<void> ret = effectsFactory->getAllDescriptors(
-      [&](Result r, const hidl_vec<EffectDescriptor>& result) {
-        if (r == Result::OK) {
-          for (const auto& desc : result) {
-            if (desc.type == type) {
-              effectFound = true;
-              *uuid = desc.uuid;
-              break;
-            }
-          }
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_TRUE(effectFound);
-}
-
-void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) {
-  Result retval;
-  EffectConfig currentConfig;
-  Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
-    retval = r;
-    if (r == Result::OK) {
-      currentConfig = conf;
-    }
-  });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-  ASSERT_TRUE(audio_channel_mask_is_valid(
-      static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels)));
-  *channelCount = audio_channel_count_from_out_mask(
-      static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels));
-}
-
-TEST_F(AudioEffectHidlTest, Close) {
-  description("Verify that an effect can be closed");
-  Return<Result> ret = effect->close();
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-}
-
-TEST_F(AudioEffectHidlTest, GetDescriptor) {
-  description(
-      "Verify that an effect can return its own descriptor via GetDescriptor");
-  Result retval = Result::NOT_INITIALIZED;
-  Uuid actualType;
-  Return<void> ret =
-      effect->getDescriptor([&](Result r, const EffectDescriptor& desc) {
-        retval = r;
-        if (r == Result::OK) {
-          actualType = desc.type;
-        }
-      });
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  EXPECT_EQ(getEffectType(), actualType);
-}
-
-TEST_F(AudioEffectHidlTest, GetSetConfig) {
-  description(
-      "Verify that it is possible to manipulate effect config via Get / "
-      "SetConfig");
-  Result retval = Result::NOT_INITIALIZED;
-  EffectConfig currentConfig;
-  Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
-    retval = r;
-    if (r == Result::OK) {
-      currentConfig = conf;
-    }
-  });
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  Return<Result> ret2 = effect->setConfig(currentConfig, nullptr, nullptr);
-  EXPECT_TRUE(ret2.isOk());
-  EXPECT_EQ(Result::OK, ret2);
-}
-
-TEST_F(AudioEffectHidlTest, GetConfigReverse) {
-  description("Verify that GetConfigReverse does not crash");
-  Return<void> ret =
-      effect->getConfigReverse([&](Result, const EffectConfig&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, GetSupportedAuxChannelsConfigs) {
-  description("Verify that GetSupportedAuxChannelsConfigs does not crash");
-  Return<void> ret = effect->getSupportedAuxChannelsConfigs(
-      0, [&](Result, const hidl_vec<EffectAuxChannelsConfig>&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, GetAuxChannelsConfig) {
-  description("Verify that GetAuxChannelsConfig does not crash");
-  Return<void> ret = effect->getAuxChannelsConfig(
-      [&](Result, const EffectAuxChannelsConfig&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, SetAuxChannelsConfig) {
-  description("Verify that SetAuxChannelsConfig does not crash");
-  Return<Result> ret = effect->setAuxChannelsConfig(EffectAuxChannelsConfig());
-  EXPECT_TRUE(ret.isOk());
-}
-
-// Not generated automatically because AudioBuffer contains
-// instances of hidl_memory which can't be compared properly
-// in general case due to presence of handles.
-//
-// However, in this particular case, handles must not present
-// thus comparison is possible.
-//
-// operator== must be defined in the same namespace as the structures.
-namespace android {
-namespace hardware {
-namespace audio {
-namespace effect {
-namespace V4_0 {
-inline bool operator==(const AudioBuffer& lhs, const AudioBuffer& rhs) {
-  return lhs.id == rhs.id && lhs.frameCount == rhs.frameCount &&
-         lhs.data.handle() == nullptr && rhs.data.handle() == nullptr;
-}
-
-inline bool operator==(const EffectBufferConfig& lhs,
-                       const EffectBufferConfig& rhs) {
-  return lhs.buffer == rhs.buffer && lhs.samplingRateHz == rhs.samplingRateHz &&
-         lhs.channels == rhs.channels && lhs.format == rhs.format &&
-         lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask;
-}
-
-inline bool operator==(const EffectConfig& lhs, const EffectConfig& rhs) {
-  return lhs.inputCfg == rhs.inputCfg && lhs.outputCfg == rhs.outputCfg;
-}
-}  // namespace V4_0
-}  // namespace effect
-}  // namespace audio
-}  // namespace hardware
-}  // namespace android
-
-TEST_F(AudioEffectHidlTest, Reset) {
-  description("Verify that Reset preserves effect configuration");
-  Result retval = Result::NOT_INITIALIZED;
-  EffectConfig originalConfig;
-  Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
-    retval = r;
-    if (r == Result::OK) {
-      originalConfig = conf;
-    }
-  });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-  Return<Result> ret2 = effect->reset();
-  EXPECT_TRUE(ret2.isOk());
-  EXPECT_EQ(Result::OK, ret2);
-  EffectConfig configAfterReset;
-  ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
-    retval = r;
-    if (r == Result::OK) {
-      configAfterReset = conf;
-    }
-  });
-  EXPECT_EQ(originalConfig, configAfterReset);
-}
-
-TEST_F(AudioEffectHidlTest, DisableEnableDisable) {
-  description("Verify Disable -> Enable -> Disable sequence for an effect");
-  Return<Result> ret = effect->disable();
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::INVALID_ARGUMENTS, ret);
-  ret = effect->enable();
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-  ret = effect->disable();
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-}
-
-TEST_F(AudioEffectHidlTest, SetDevice) {
-  description("Verify that SetDevice works for an output chain effect");
-  Return<Result> ret = effect->setDevice(mkBitfield(AudioDevice::OUT_SPEAKER));
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-}
-
-TEST_F(AudioEffectHidlTest, SetAndGetVolume) {
-  description("Verify that SetAndGetVolume method works for an effect");
-  uint32_t channelCount;
-  getChannelCount(&channelCount);
-  hidl_vec<uint32_t> volumes;
-  volumes.resize(channelCount);
-  for (uint32_t i = 0; i < channelCount; ++i) {
-    volumes[i] = 0;
-  }
-  Result retval = Result::NOT_INITIALIZED;
-  Return<void> ret = effect->setAndGetVolume(
-      volumes, [&](Result r, const hidl_vec<uint32_t>&) { retval = r; });
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, retval);
-}
-
-TEST_F(AudioEffectHidlTest, VolumeChangeNotification) {
-  description("Verify that effect accepts VolumeChangeNotification");
-  uint32_t channelCount;
-  getChannelCount(&channelCount);
-  hidl_vec<uint32_t> volumes;
-  volumes.resize(channelCount);
-  for (uint32_t i = 0; i < channelCount; ++i) {
-    volumes[i] = 0;
-  }
-  Return<Result> ret = effect->volumeChangeNotification(volumes);
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-}
-
-TEST_F(AudioEffectHidlTest, SetAudioMode) {
-  description("Verify that SetAudioMode works for an effect");
-  Return<Result> ret = effect->setAudioMode(AudioMode::NORMAL);
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-}
-
-TEST_F(AudioEffectHidlTest, SetConfigReverse) {
-  description("Verify that SetConfigReverse does not crash");
-  Return<Result> ret =
-      effect->setConfigReverse(EffectConfig(), nullptr, nullptr);
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, SetInputDevice) {
-  description("Verify that SetInputDevice does not crash");
-  Return<Result> ret = effect->setInputDevice(mkBitfield(AudioDevice::IN_BUILTIN_MIC));
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, SetAudioSource) {
-  description("Verify that SetAudioSource does not crash");
-  Return<Result> ret = effect->setAudioSource(AudioSource::MIC);
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, Offload) {
-  description("Verify that calling Offload method does not crash");
-  EffectOffloadParameter offloadParam;
-  offloadParam.isOffload = false;
-  offloadParam.ioHandle =
-      static_cast<int>(AudioHandleConsts::AUDIO_IO_HANDLE_NONE);
-  Return<Result> ret = effect->offload(offloadParam);
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, PrepareForProcessing) {
-  description("Verify that PrepareForProcessing method works for an effect");
-  Result retval = Result::NOT_INITIALIZED;
-  Return<void> ret = effect->prepareForProcessing(
-      [&](Result r, const MQDescriptorSync<Result>&) { retval = r; });
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, retval);
-}
-
-TEST_F(AudioEffectHidlTest, SetProcessBuffers) {
-  description("Verify that SetProcessBuffers works for an effect");
-  sp<IAllocator> ashmem = IAllocator::getService("ashmem");
-  ASSERT_NE(nullptr, ashmem.get());
-  bool success = false;
-  AudioBuffer buffer;
-  Return<void> ret =
-      ashmem->allocate(1024, [&](bool s, const hidl_memory& memory) {
-        success = s;
-        if (s) {
-          buffer.data = memory;
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_TRUE(success);
-  Return<Result> ret2 = effect->setProcessBuffers(buffer, buffer);
-  EXPECT_TRUE(ret2.isOk());
-  EXPECT_EQ(Result::OK, ret2);
-}
-
-TEST_F(AudioEffectHidlTest, Command) {
-  description("Verify that Command does not crash");
-  Return<void> ret = effect->command(0, hidl_vec<uint8_t>(), 0,
-                                     [&](int32_t, const hidl_vec<uint8_t>&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, SetParameter) {
-  description("Verify that SetParameter does not crash");
-  Return<Result> ret =
-      effect->setParameter(hidl_vec<uint8_t>(), hidl_vec<uint8_t>());
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, GetParameter) {
-  description("Verify that GetParameter does not crash");
-  Return<void> ret = effect->getParameter(
-      hidl_vec<uint8_t>(), 0, [&](Result, const hidl_vec<uint8_t>&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, GetSupportedConfigsForFeature) {
-  description("Verify that GetSupportedConfigsForFeature does not crash");
-  Return<void> ret = effect->getSupportedConfigsForFeature(
-      0, 0, 0, [&](Result, uint32_t, const hidl_vec<uint8_t>&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, GetCurrentConfigForFeature) {
-  description("Verify that GetCurrentConfigForFeature does not crash");
-  Return<void> ret = effect->getCurrentConfigForFeature(
-      0, 0, [&](Result, const hidl_vec<uint8_t>&) {});
-  EXPECT_TRUE(ret.isOk());
-}
-
-TEST_F(AudioEffectHidlTest, SetCurrentConfigForFeature) {
-  description("Verify that SetCurrentConfigForFeature does not crash");
-  Return<Result> ret =
-      effect->setCurrentConfigForFeature(0, hidl_vec<uint8_t>());
-  EXPECT_TRUE(ret.isOk());
-}
-
-
-// The main test class for Equalizer Audio Effect HIDL HAL.
-class EqualizerAudioEffectHidlTest : public AudioEffectHidlTest {
- public:
-  void SetUp() override {
-    AudioEffectHidlTest::SetUp();
-    equalizer = IEqualizerEffect::castFrom(effect);
-    ASSERT_NE(nullptr, equalizer.get());
-  }
-
- protected:
-  Uuid getEffectType() override { return EQUALIZER_EFFECT_TYPE; }
-  void getNumBands(uint16_t* numBands);
-  void getLevelRange(int16_t* minLevel, int16_t* maxLevel);
-  void getBandFrequencyRange(uint16_t band, uint32_t* minFreq,
-                             uint32_t* centerFreq, uint32_t* maxFreq);
-  void getPresetCount(size_t* count);
-
-  sp<IEqualizerEffect> equalizer;
-};
-
-void EqualizerAudioEffectHidlTest::getNumBands(uint16_t* numBands) {
-  Result retval = Result::NOT_INITIALIZED;
-  Return<void> ret = equalizer->getNumBands([&](Result r, uint16_t b) {
-    retval = r;
-    if (retval == Result::OK) {
-      *numBands = b;
-    }
-  });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-}
-
-void EqualizerAudioEffectHidlTest::getLevelRange(int16_t* minLevel,
-                                                 int16_t* maxLevel) {
-  Result retval = Result::NOT_INITIALIZED;
-  Return<void> ret =
-      equalizer->getLevelRange([&](Result r, int16_t min, int16_t max) {
-        retval = r;
-        if (retval == Result::OK) {
-          *minLevel = min;
-          *maxLevel = max;
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-}
-
-void EqualizerAudioEffectHidlTest::getBandFrequencyRange(uint16_t band,
-                                                         uint32_t* minFreq,
-                                                         uint32_t* centerFreq,
-                                                         uint32_t* maxFreq) {
-  Result retval = Result::NOT_INITIALIZED;
-  Return<void> ret = equalizer->getBandFrequencyRange(
-      band, [&](Result r, uint32_t min, uint32_t max) {
-        retval = r;
-        if (retval == Result::OK) {
-          *minFreq = min;
-          *maxFreq = max;
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-  ret = equalizer->getBandCenterFrequency(band, [&](Result r, uint32_t center) {
-    retval = r;
-    if (retval == Result::OK) {
-      *centerFreq = center;
-    }
-  });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-}
-
-void EqualizerAudioEffectHidlTest::getPresetCount(size_t* count) {
-  Result retval = Result::NOT_INITIALIZED;
-  Return<void> ret = equalizer->getPresetNames(
-      [&](Result r, const hidl_vec<hidl_string>& names) {
-        retval = r;
-        if (retval == Result::OK) {
-          *count = names.size();
-        }
-      });
-  ASSERT_TRUE(ret.isOk());
-  ASSERT_EQ(Result::OK, retval);
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetNumBands) {
-  description("Verify that Equalizer effect reports at least one band");
-  uint16_t numBands = 0;
-  getNumBands(&numBands);
-  EXPECT_GT(numBands, 0);
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetLevelRange) {
-  description("Verify that Equalizer effect reports adequate band level range");
-  int16_t minLevel = 0x7fff, maxLevel = 0;
-  getLevelRange(&minLevel, &maxLevel);
-  EXPECT_GT(maxLevel, minLevel);
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetSetBandLevel) {
-  description(
-      "Verify that manipulating band levels works for Equalizer effect");
-  uint16_t numBands = 0;
-  getNumBands(&numBands);
-  ASSERT_GT(numBands, 0);
-  int16_t levels[3]{0x7fff, 0, 0};
-  getLevelRange(&levels[0], &levels[2]);
-  ASSERT_GT(levels[2], levels[0]);
-  levels[1] = (levels[2] + levels[0]) / 2;
-  for (uint16_t i = 0; i < numBands; ++i) {
-    for (size_t j = 0; j < ARRAY_SIZE(levels); ++j) {
-      Return<Result> ret = equalizer->setBandLevel(i, levels[j]);
-      EXPECT_TRUE(ret.isOk());
-      EXPECT_EQ(Result::OK, ret);
-      Result retval = Result::NOT_INITIALIZED;
-      int16_t actualLevel;
-      Return<void> ret2 = equalizer->getBandLevel(i, [&](Result r, int16_t l) {
-        retval = r;
-        if (retval == Result::OK) {
-          actualLevel = l;
-        }
-      });
-      EXPECT_TRUE(ret2.isOk());
-      EXPECT_EQ(Result::OK, retval);
-      EXPECT_EQ(levels[j], actualLevel);
-    }
-  }
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetBandCenterFrequencyAndRange) {
-  description(
-      "Verify that Equalizer effect reports adequate band frequency range");
-  uint16_t numBands = 0;
-  getNumBands(&numBands);
-  ASSERT_GT(numBands, 0);
-  for (uint16_t i = 0; i < numBands; ++i) {
-    uint32_t minFreq = 0xffffffff, centerFreq = 0xffffffff,
-             maxFreq = 0xffffffff;
-    getBandFrequencyRange(i, &minFreq, &centerFreq, &maxFreq);
-    // Note: NXP legacy implementation reports "1" as upper bound for last band,
-    // so this check fails.
-    EXPECT_GE(maxFreq, centerFreq);
-    EXPECT_GE(centerFreq, minFreq);
-  }
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetBandForFrequency) {
-  description(
-      "Verify that Equalizer effect supports GetBandForFrequency correctly");
-  uint16_t numBands = 0;
-  getNumBands(&numBands);
-  ASSERT_GT(numBands, 0);
-  for (uint16_t i = 0; i < numBands; ++i) {
-    uint32_t freqs[3]{0, 0, 0};
-    getBandFrequencyRange(i, &freqs[0], &freqs[1], &freqs[2]);
-    // NXP legacy implementation reports "1" as upper bound for last band, some
-    // of the checks fail.
-    for (size_t j = 0; j < ARRAY_SIZE(freqs); ++j) {
-      if (j == 0) {
-        freqs[j]++;
-      }  // Min frequency is an open interval.
-      Result retval = Result::NOT_INITIALIZED;
-      uint16_t actualBand = numBands + 1;
-      Return<void> ret =
-          equalizer->getBandForFrequency(freqs[j], [&](Result r, uint16_t b) {
-            retval = r;
-            if (retval == Result::OK) {
-              actualBand = b;
-            }
-          });
-      EXPECT_TRUE(ret.isOk());
-      EXPECT_EQ(Result::OK, retval);
-      EXPECT_EQ(i, actualBand) << "Frequency: " << freqs[j];
-    }
-  }
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetPresetNames) {
-  description("Verify that Equalizer effect reports at least one preset");
-  size_t presetCount;
-  getPresetCount(&presetCount);
-  EXPECT_GT(presetCount, 0u);
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetSetCurrentPreset) {
-  description(
-      "Verify that manipulating the current preset for Equalizer effect");
-  size_t presetCount;
-  getPresetCount(&presetCount);
-  ASSERT_GT(presetCount, 0u);
-  for (uint16_t i = 0; i < presetCount; ++i) {
-    Return<Result> ret = equalizer->setCurrentPreset(i);
-    EXPECT_TRUE(ret.isOk());
-    EXPECT_EQ(Result::OK, ret);
-    Result retval = Result::NOT_INITIALIZED;
-    uint16_t actualPreset = 0xffff;
-    Return<void> ret2 = equalizer->getCurrentPreset([&](Result r, uint16_t p) {
-      retval = r;
-      if (retval == Result::OK) {
-        actualPreset = p;
-      }
-    });
-    EXPECT_TRUE(ret2.isOk());
-    EXPECT_EQ(Result::OK, retval);
-    EXPECT_EQ(i, actualPreset);
-  }
-}
-
-TEST_F(EqualizerAudioEffectHidlTest, GetSetAllProperties) {
-  description(
-      "Verify that setting band levels and presets works via Get / "
-      "SetAllProperties for Equalizer effect");
-  using AllProperties =
-      android::hardware::audio::effect::V4_0::IEqualizerEffect::AllProperties;
-  uint16_t numBands = 0;
-  getNumBands(&numBands);
-  ASSERT_GT(numBands, 0);
-  AllProperties props;
-  props.bandLevels.resize(numBands);
-  for (size_t i = 0; i < numBands; ++i) {
-    props.bandLevels[i] = 0;
-  }
-
-  AllProperties actualProps;
-  Result retval = Result::NOT_INITIALIZED;
-
-  // Verify setting of the band levels via properties.
-  props.curPreset = -1;
-  Return<Result> ret = equalizer->setAllProperties(props);
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-  Return<void> ret2 =
-      equalizer->getAllProperties([&](Result r, AllProperties p) {
-        retval = r;
-        if (retval == Result::OK) {
-          actualProps = p;
-        }
-      });
-  EXPECT_TRUE(ret2.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  EXPECT_EQ(props.bandLevels, actualProps.bandLevels);
-
-  // Verify setting of the current preset via properties.
-  props.curPreset = 0;  // Assuming there is at least one preset.
-  ret = equalizer->setAllProperties(props);
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-  ret2 = equalizer->getAllProperties([&](Result r, AllProperties p) {
-    retval = r;
-    if (retval == Result::OK) {
-      actualProps = p;
-    }
-  });
-  EXPECT_TRUE(ret2.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  EXPECT_EQ(props.curPreset, actualProps.curPreset);
-}
-
-// The main test class for Equalizer Audio Effect HIDL HAL.
-class LoudnessEnhancerAudioEffectHidlTest : public AudioEffectHidlTest {
- public:
-  void SetUp() override {
-    AudioEffectHidlTest::SetUp();
-    enhancer = ILoudnessEnhancerEffect::castFrom(effect);
-    ASSERT_NE(nullptr, enhancer.get());
-  }
-
- protected:
-  Uuid getEffectType() override { return LOUDNESS_ENHANCER_EFFECT_TYPE; }
-
-  sp<ILoudnessEnhancerEffect> enhancer;
-};
-
-TEST_F(LoudnessEnhancerAudioEffectHidlTest, GetSetTargetGain) {
-  description(
-      "Verify that manipulating the target gain works for Loudness Enhancer "
-      "effect");
-  const int32_t gain = 100;
-  Return<Result> ret = enhancer->setTargetGain(gain);
-  EXPECT_TRUE(ret.isOk());
-  EXPECT_EQ(Result::OK, ret);
-  int32_t actualGain = 0;
-  Result retval;
-  Return<void> ret2 = enhancer->getTargetGain([&](Result r, int32_t g) {
-    retval = r;
-    if (retval == Result::OK) {
-      actualGain = g;
-    }
-  });
-  EXPECT_TRUE(ret2.isOk());
-  EXPECT_EQ(Result::OK, retval);
-  EXPECT_EQ(gain, actualGain);
-}
-
-int main(int argc, char** argv) {
-    ::testing::AddGlobalTestEnvironment(AudioEffectsFactoryHidlEnvironment::Instance());
-    ::testing::InitGoogleTest(&argc, argv);
-    AudioEffectsFactoryHidlEnvironment::Instance()->init(&argc, argv);
-    int status = RUN_ALL_TESTS();
-    LOG(INFO) << "Test result = " << status;
-    return status;
-}
diff --git a/audio/effect/4.0/xml/audio_effects_conf.xsd b/audio/effect/4.0/xml/audio_effects_conf.xsd
new file mode 120000
index 0000000..9d85fa7
--- /dev/null
+++ b/audio/effect/4.0/xml/audio_effects_conf.xsd
@@ -0,0 +1 @@
+../../2.0/xml/audio_effects_conf.xsd
\ No newline at end of file
diff --git a/audio/effect/4.0/xml/audio_effects_conf_V4_0.xsd b/audio/effect/4.0/xml/audio_effects_conf_V4_0.xsd
deleted file mode 120000
index 82d569a..0000000
--- a/audio/effect/4.0/xml/audio_effects_conf_V4_0.xsd
+++ /dev/null
@@ -1 +0,0 @@
-../../2.0/xml/audio_effects_conf_V2_0.xsd
\ No newline at end of file
diff --git a/audio/effect/5.0/Android.bp b/audio/effect/5.0/Android.bp
new file mode 100644
index 0000000..d60d94a
--- /dev/null
+++ b/audio/effect/5.0/Android.bp
@@ -0,0 +1,47 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.audio.effect@5.0",
+    root: "android.hardware",
+    vndk: {
+        enabled: true,
+    },
+    srcs: [
+        "types.hal",
+        "IAcousticEchoCancelerEffect.hal",
+        "IAutomaticGainControlEffect.hal",
+        "IBassBoostEffect.hal",
+        "IDownmixEffect.hal",
+        "IEffect.hal",
+        "IEffectBufferProviderCallback.hal",
+        "IEffectsFactory.hal",
+        "IEnvironmentalReverbEffect.hal",
+        "IEqualizerEffect.hal",
+        "ILoudnessEnhancerEffect.hal",
+        "INoiseSuppressionEffect.hal",
+        "IPresetReverbEffect.hal",
+        "IVirtualizerEffect.hal",
+        "IVisualizerEffect.hal",
+    ],
+    interfaces: [
+        "android.hardware.audio.common@5.0",
+        "android.hidl.base@1.0",
+    ],
+    types: [
+        "AudioBuffer",
+        "EffectAuxChannelsConfig",
+        "EffectBufferAccess",
+        "EffectBufferConfig",
+        "EffectConfig",
+        "EffectConfigParameters",
+        "EffectDescriptor",
+        "EffectFeature",
+        "EffectFlags",
+        "EffectOffloadParameter",
+        "MessageQueueFlagBits",
+        "Result",
+    ],
+    gen_java: false,
+    gen_java_constants: true,
+}
+
diff --git a/audio/effect/5.0/IAcousticEchoCancelerEffect.hal b/audio/effect/5.0/IAcousticEchoCancelerEffect.hal
new file mode 100644
index 0000000..61cdc95
--- /dev/null
+++ b/audio/effect/5.0/IAcousticEchoCancelerEffect.hal
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+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/5.0/IAutomaticGainControlEffect.hal b/audio/effect/5.0/IAutomaticGainControlEffect.hal
new file mode 100644
index 0000000..ae354ec
--- /dev/null
+++ b/audio/effect/5.0/IAutomaticGainControlEffect.hal
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+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);
+
+    struct AllProperties {
+        int16_t targetLevelMb;
+        int16_t compGainMb;
+        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/5.0/IBassBoostEffect.hal b/audio/effect/5.0/IBassBoostEffect.hal
new file mode 100644
index 0000000..4b3b629
--- /dev/null
+++ b/audio/effect/5.0/IBassBoostEffect.hal
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+import IEffect;
+
+interface IBassBoostEffect extends IEffect {
+    /**
+     * Returns whether setting bass boost strength is supported.
+     */
+    isStrengthSupported() generates (Result retval, bool strengthSupported);
+
+    enum StrengthRange : uint16_t {
+        MIN = 0,
+        MAX = 1000
+    };
+
+    /**
+     * Sets bass boost strength.
+     *
+     * @param strength strength of the effect. The valid range for strength
+     *                 strength is [0, 1000], where 0 per mille designates the
+     *                 mildest effect and 1000 per mille designates the
+     *                 strongest.
+     * @return retval operation completion status.
+     */
+    setStrength(uint16_t strength) generates (Result retval);
+
+    /**
+     * Gets virtualization strength.
+     */
+    getStrength() generates (Result retval, uint16_t strength);
+};
diff --git a/audio/effect/5.0/IDownmixEffect.hal b/audio/effect/5.0/IDownmixEffect.hal
new file mode 100644
index 0000000..43d4b23
--- /dev/null
+++ b/audio/effect/5.0/IDownmixEffect.hal
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+import IEffect;
+
+interface IDownmixEffect extends IEffect {
+    enum Type : int32_t {
+        STRIP, // throw away the extra channels
+        FOLD   // mix the extra channels with FL/FR
+    };
+
+    /**
+     * Sets the current downmix preset.
+     */
+    setType(Type preset) generates (Result retval);
+
+    /**
+     * Gets the current downmix preset.
+     */
+    getType() generates (Result retval, Type preset);
+};
diff --git a/audio/effect/5.0/IEffect.hal b/audio/effect/5.0/IEffect.hal
new file mode 100644
index 0000000..9c50963
--- /dev/null
+++ b/audio/effect/5.0/IEffect.hal
@@ -0,0 +1,418 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+import IEffectBufferProviderCallback;
+
+interface IEffect {
+    /**
+     * Initialize effect engine--all configurations return to default.
+     *
+     * @return retval operation completion status.
+     */
+    @entry
+    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.
+     *
+     * @param config configuration descriptor.
+     * @param inputBufferProvider optional buffer provider reference.
+     * @param outputBufferProvider optional buffer provider reference.
+     * @return retval operation completion status.
+     */
+    setConfig(EffectConfig config,
+            IEffectBufferProviderCallback inputBufferProvider,
+            IEffectBufferProviderCallback outputBufferProvider)
+            generates (Result retval);
+
+    /**
+     * Reset the effect engine. Keep configuration but resets state and buffer
+     * content.
+     *
+     * @return retval operation completion status.
+     */
+    reset() generates (Result retval);
+
+    /**
+     * Enable processing.
+     *
+     * @return retval operation completion status.
+     */
+    @callflow(next={"prepareForProcessing"})
+    enable() generates (Result retval);
+
+    /**
+     * Disable processing.
+     *
+     * @return retval operation completion status.
+     */
+    @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.
+     *
+     * Note: this method is only supported for effects inserted into
+     *       the output chain.
+     *
+     * @param device output device specification.
+     * @return retval operation completion status.
+     */
+    setDevice(bitfield<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
+     * return the volume that should be applied before the effect is
+     * processed. The overall volume (the volume actually applied by the effect
+     * engine multiplied by the returned value) should match the value indicated
+     * in the command.
+     *
+     * @param volumes vector containing volume for each channel defined in
+     *                EffectConfig for output buffer expressed in 8.24 fixed
+     *                point format.
+     * @return result updated volume values.
+     * @return retval operation completion status.
+     */
+    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.
+     *
+     * @param volumes vector containing volume for each channel defined in
+     *                EffectConfig for output buffer expressed in 8.24 fixed
+     *                point format.
+     * @return retval operation completion status.
+     */
+    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.
+     *
+     * @param mode desired audio mode.
+     * @return retval operation completion status.
+     */
+    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.
+     *
+     * @param config configuration descriptor.
+     * @param inputBufferProvider optional buffer provider reference.
+     * @param outputBufferProvider optional buffer provider reference.
+     * @return retval operation completion status.
+     */
+    setConfigReverse(EffectConfig config,
+            IEffectBufferProviderCallback inputBufferProvider,
+            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.
+     *
+     * Note: this method is only supported for effects inserted into
+     *       the input chain.
+     *
+     * @param device input device specification.
+     * @return retval operation completion status.
+     */
+    setInputDevice(bitfield<AudioDevice> device) generates (Result retval);
+
+    /**
+     * Read audio parameters configurations for input and output buffers.
+     *
+     * @return retval operation completion status.
+     * @return config configuration descriptor.
+     */
+    getConfig() generates (Result retval, EffectConfig config);
+
+    /**
+     * Read audio parameters configurations for input and output buffers of
+     * reverse stream.
+     *
+     * @return retval operation completion status.
+     * @return config configuration descriptor.
+     */
+    getConfigReverse() generates (Result retval, EffectConfig config);
+
+    /**
+     * Queries for supported combinations of main and auxiliary channels
+     * (e.g. for a multi-microphone noise suppressor).
+     *
+     * @param maxConfigs maximum number of the combinations to return.
+     * @return retval absence of the feature support is indicated using
+     *                NOT_SUPPORTED code. RESULT_TOO_BIG is returned if
+     *                the number of supported combinations exceeds 'maxConfigs'.
+     * @return result list of configuration descriptors.
+     */
+    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
+     *                NOT_SUPPORTED code.
+     * @return result configuration descriptor.
+     */
+    getAuxChannelsConfig()
+            generates (Result retval, EffectAuxChannelsConfig result);
+
+    /**
+     * Sets the current configuration of main and auxiliary channels.
+     *
+     * @return retval operation completion status; absence of the feature
+     *                support is indicated using NOT_SUPPORTED code.
+     */
+    setAuxChannelsConfig(EffectAuxChannelsConfig config)
+            generates (Result retval);
+
+    /**
+     * Set the audio source the capture path is configured for (Camcorder, voice
+     * recognition...).
+     *
+     * Note: this method is only supported for effects inserted into
+     *       the input chain.
+     *
+     * @param source source descriptor.
+     * @return retval operation completion status.
+     */
+    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.
+     *
+     * @param param effect offload descriptor.
+     * @return retval operation completion status.
+     */
+    offload(EffectOffloadParameter param) generates (Result retval);
+
+    /**
+     * Returns the effect descriptor.
+     *
+     * @return retval operation completion status.
+     * @return descriptor effect descriptor.
+     */
+    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
+     * effect processing operation status. The shared memory is set up
+     * separately using 'setProcessBuffers' method.
+     *
+     * Processing is requested by setting 'REQUEST_PROCESS' or
+     * 'REQUEST_PROCESS_REVERSE' EventFlags associated with the status message
+     * queue. The result of processing may be one of the following:
+     *   OK if there were no errors during processing;
+     *   INVALID_ARGUMENTS if audio buffers are invalid;
+     *   INVALID_STATE if the engine has finished the disable phase;
+     *   NOT_INITIALIZED if the audio buffers were not set;
+     *   NOT_SUPPORTED if the requested processing type is not supported by
+     *                 the effect.
+     *
+     * @return retval OK if both message queues were created successfully.
+     *                INVALID_STATE if the method was already called.
+     *                INVALID_ARGUMENTS if there was a problem setting up
+     *                                  the queue.
+     * @return statusMQ a message queue used for passing status from the effect.
+     */
+    @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.
+     *
+     * The input and the output buffer may be reused between different effects,
+     * and the input buffer may be used as an output buffer. Buffers are
+     * distinguished using 'AudioBuffer.id' field.
+     *
+     * @param inBuffer input audio buffer.
+     * @param outBuffer output audio buffer.
+     * @return retval OK if both buffers were mapped successfully.
+     *                INVALID_ARGUMENTS if there was a problem with mapping
+     *                                  any of the buffers.
+     */
+    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.
+     *
+     * The effect must use standard POSIX.1-2001 error codes for the operation
+     * completion status.
+     *
+     * Use this method only if the effect is provided by a third party, and
+     * there is no interface defined for it. This method only works for effects
+     * implemented in software.
+     *
+     * @param commandId the ID of the command.
+     * @param data command data.
+     * @param resultMaxSize maximum size in bytes of the result; can be 0.
+     * @return status command completion status.
+     * @return result result data.
+     */
+    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.
+     *
+     * The effect must use INVALID_ARGUMENTS return code if the parameter ID is
+     * unknown or if provided parameter data is invalid. If the effect does not
+     * support setting vendor-specific parameters, it must return NOT_SUPPORTED.
+     *
+     * Use this method only if the effect is provided by a third party, and
+     * there is no interface defined for it. This method only works for effects
+     * implemented in software.
+     *
+     * @param parameter identifying data of the parameter.
+     * @param value the value of the parameter.
+     * @return retval operation completion status.
+     */
+    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.
+     *
+     * The effect must use INVALID_ARGUMENTS return code if the parameter ID is
+     * unknown. If the effect does not support setting vendor-specific
+     * parameters, it must return NOT_SUPPORTED.
+     *
+     * Use this method only if the effect is provided by a third party, and
+     * there is no interface defined for it.  This method only works for effects
+     * implemented in software.
+     *
+     * @param parameter identifying data of the parameter.
+     * @param valueMaxSize maximum size in bytes of the value.
+     * @return retval operation completion status.
+     * @return result the value of the parameter.
+     */
+    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.
+     *
+     * The effect must use INVALID_ARGUMENTS return code if the feature ID is
+     * unknown. If the effect does not support getting vendor-specific feature
+     * configs, it must return NOT_SUPPORTED. If the feature is supported but
+     * the total number of supported configurations exceeds the maximum number
+     * indicated by the caller, the method must return RESULT_TOO_BIG.
+     *
+     * Use this method only if the effect is provided by a third party, and
+     * there is no interface defined for it.  This method only works for effects
+     * implemented in software.
+     *
+     * @param featureId feature identifier.
+     * @param maxConfigs maximum number of configs to return.
+     * @param configSize size of each config in bytes.
+     * @return retval operation completion status.
+     * @return configsCount number of configs returned.
+     * @return configsData data for all the configs returned.
+     */
+    getSupportedConfigsForFeature(
+            uint32_t featureId,
+            uint32_t maxConfigs,
+            uint32_t configSize) generates (
+                    Result retval,
+                    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.
+     *
+     * The effect must use INVALID_ARGUMENTS return code if the feature ID is
+     * unknown. If the effect does not support getting vendor-specific
+     * feature configs, it must return NOT_SUPPORTED.
+     *
+     * Use this method only if the effect is provided by a third party, and
+     * there is no interface defined for it.  This method only works for effects
+     * implemented in software.
+     *
+     * @param featureId feature identifier.
+     * @param configSize size of the config in bytes.
+     * @return retval operation completion status.
+     * @return configData config data.
+     */
+    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.
+     *
+     * The effect must use INVALID_ARGUMENTS return code if the feature ID is
+     * unknown. If the effect does not support getting vendor-specific
+     * feature configs, it must return NOT_SUPPORTED.
+     *
+     * Use this method only if the effect is provided by a third party, and
+     * there is no interface defined for it.  This method only works for effects
+     * implemented in software.
+     *
+     * @param featureId feature identifier.
+     * @param configData config data.
+     * @return retval operation completion status.
+     */
+    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.
+     *
+     * @return retval OK in case the success.
+     *                INVALID_STATE if the effect was already closed.
+     */
+    @exit
+    close() generates (Result retval);
+};
diff --git a/audio/effect/5.0/IEffectBufferProviderCallback.hal b/audio/effect/5.0/IEffectBufferProviderCallback.hal
new file mode 100644
index 0000000..aabd15e
--- /dev/null
+++ b/audio/effect/5.0/IEffectBufferProviderCallback.hal
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.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.
+     *
+     * @return buffer audio buffer for processing
+     */
+    getBuffer() generates (AudioBuffer buffer);
+
+    /**
+     * Called to provide a buffer with the data written by 'process' function.
+     *
+     * @param buffer audio buffer for processing
+     */
+    putBuffer(AudioBuffer buffer);
+};
diff --git a/audio/effect/5.0/IEffectsFactory.hal b/audio/effect/5.0/IEffectsFactory.hal
new file mode 100644
index 0000000..a88b381
--- /dev/null
+++ b/audio/effect/5.0/IEffectsFactory.hal
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+import IEffect;
+
+interface IEffectsFactory {
+    /**
+     * Returns descriptors of different effects in all loaded libraries.
+     *
+     * @return retval operation completion status.
+     * @return result list of effect descriptors.
+     */
+    getAllDescriptors() generates(Result retval, vec<EffectDescriptor> result);
+
+    /**
+     * Returns a descriptor of a particular effect.
+     *
+     * @return retval operation completion status.
+     * @return result effect descriptor.
+     */
+    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.
+     *
+     * @param uid effect uuid.
+     * @param session audio session to which this effect instance will be
+     *                attached.  All effects created with the same session ID
+     *                are connected in series and process the same signal
+     *                stream.
+     * @param ioHandle identifies the output or input stream this effect is
+     *                 directed to in audio HAL.
+     * @return retval operation completion status.
+     * @return result the interface for the created effect.
+     * @return effectId the unique ID of the effect to be used with
+     *                  IStream::addEffect and IStream::removeEffect methods.
+     */
+    createEffect(Uuid uid, AudioSession session, AudioIoHandle ioHandle)
+        generates (Result retval, IEffect result, uint64_t effectId);
+};
diff --git a/audio/effect/5.0/IEnvironmentalReverbEffect.hal b/audio/effect/5.0/IEnvironmentalReverbEffect.hal
new file mode 100644
index 0000000..ffc4312
--- /dev/null
+++ b/audio/effect/5.0/IEnvironmentalReverbEffect.hal
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+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);
+
+    enum ParamRange : int16_t {
+        ROOM_LEVEL_MIN = -6000,
+        ROOM_LEVEL_MAX = 0,
+        ROOM_HF_LEVEL_MIN = -4000,
+        ROOM_HF_LEVEL_MAX = 0,
+        DECAY_TIME_MIN = 100,
+        DECAY_TIME_MAX = 20000,
+        DECAY_HF_RATIO_MIN = 100,
+        DECAY_HF_RATIO_MAX = 1000,
+        REFLECTIONS_LEVEL_MIN = -6000,
+        REFLECTIONS_LEVEL_MAX = 0,
+        REFLECTIONS_DELAY_MIN = 0,
+        REFLECTIONS_DELAY_MAX = 65,
+        REVERB_LEVEL_MIN = -6000,
+        REVERB_LEVEL_MAX = 0,
+        REVERB_DELAY_MIN = 0,
+        REVERB_DELAY_MAX = 65,
+        DIFFUSION_MIN = 0,
+        DIFFUSION_MAX = 1000,
+        DENSITY_MIN = 0,
+        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 frequencies level.
+     */
+    setRoomHfLevel(int16_t roomHfLevel) generates (Result retval);
+
+    /**
+     * Gets the room high frequencies 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 frequencies decay.
+     */
+    setDecayHfRatio(int16_t decayHfRatio) generates (Result retval);
+
+    /**
+     * Gets the ratio of high frequencies 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);
+
+    struct AllProperties {
+        int16_t  roomLevel;         // in millibels,    range -6000 to 0
+        int16_t  roomHfLevel;       // in millibels,    range -4000 to 0
+        uint32_t decayTime;         // in milliseconds, range 100 to 20000
+        int16_t  decayHfRatio;      // in permilles,    range 100 to 1000
+        int16_t  reflectionsLevel;  // in millibels,    range -6000 to 0
+        uint32_t reflectionsDelay;  // in milliseconds, range 0 to 65
+        int16_t  reverbLevel;       // in millibels,    range -6000 to 0
+        uint32_t reverbDelay;       // in milliseconds, range 0 to 65
+        int16_t  diffusion;         // in permilles,    range 0 to 1000
+        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/5.0/IEqualizerEffect.hal b/audio/effect/5.0/IEqualizerEffect.hal
new file mode 100644
index 0000000..c9829f3
--- /dev/null
+++ b/audio/effect/5.0/IEqualizerEffect.hal
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+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);
+
+    struct AllProperties {
+        uint16_t curPreset;
+        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/5.0/ILoudnessEnhancerEffect.hal b/audio/effect/5.0/ILoudnessEnhancerEffect.hal
new file mode 100644
index 0000000..eaf8949
--- /dev/null
+++ b/audio/effect/5.0/ILoudnessEnhancerEffect.hal
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+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/5.0/INoiseSuppressionEffect.hal b/audio/effect/5.0/INoiseSuppressionEffect.hal
new file mode 100644
index 0000000..5de794f
--- /dev/null
+++ b/audio/effect/5.0/INoiseSuppressionEffect.hal
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+import IEffect;
+
+interface INoiseSuppressionEffect extends IEffect {
+    enum Level : int32_t {
+        LOW,
+        MEDIUM,
+        HIGH
+    };
+
+    /**
+     * Sets suppression level.
+     */
+    setSuppressionLevel(Level level) generates (Result retval);
+
+    /**
+     * Gets suppression level.
+     */
+    getSuppressionLevel() generates (Result retval, Level level);
+
+    enum Type : int32_t {
+        SINGLE_CHANNEL,
+        MULTI_CHANNEL
+    };
+
+    /**
+     * Set suppression type.
+     */
+    setSuppressionType(Type type) generates (Result retval);
+
+    /**
+     * Get suppression type.
+     */
+    getSuppressionType() generates (Result retval, Type type);
+
+    struct AllProperties {
+        Level level;
+        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/5.0/IPresetReverbEffect.hal b/audio/effect/5.0/IPresetReverbEffect.hal
new file mode 100644
index 0000000..af3b3ac
--- /dev/null
+++ b/audio/effect/5.0/IPresetReverbEffect.hal
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+import IEffect;
+
+interface IPresetReverbEffect extends IEffect {
+    enum Preset : int32_t {
+        NONE,        // no reverb or reflections
+        SMALLROOM,   // a small room less than five meters in length
+        MEDIUMROOM,  // a medium room with a length of ten meters or less
+        LARGEROOM,   // a large-sized room suitable for live performances
+        MEDIUMHALL,  // a medium-sized hall
+        LARGEHALL,   // a large-sized hall suitable for a full orchestra
+        PLATE,       // synthesis of the traditional plate reverb
+        LAST = PLATE
+    };
+
+    /**
+     * Sets the current preset.
+     */
+    setPreset(Preset preset) generates (Result retval);
+
+    /**
+     * Gets the current preset.
+     */
+    getPreset() generates (Result retval, Preset preset);
+};
diff --git a/audio/effect/5.0/IVirtualizerEffect.hal b/audio/effect/5.0/IVirtualizerEffect.hal
new file mode 100644
index 0000000..9402958
--- /dev/null
+++ b/audio/effect/5.0/IVirtualizerEffect.hal
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+import IEffect;
+
+interface IVirtualizerEffect extends IEffect {
+    /**
+     * Returns whether setting virtualization strength is supported.
+     */
+    isStrengthSupported() generates (bool strengthSupported);
+
+    enum StrengthRange : uint16_t {
+        MIN = 0,
+        MAX = 1000
+    };
+
+    /**
+     * Sets virtualization strength.
+     *
+     * @param strength strength of the effect. The valid range for strength
+     *                 strength is [0, 1000], where 0 per mille designates the
+     *                 mildest effect and 1000 per mille designates the
+     *                 strongest.
+     * @return retval operation completion status.
+     */
+    setStrength(uint16_t strength) generates (Result retval);
+
+    /**
+     * Gets virtualization strength.
+     */
+    getStrength() generates (Result retval, uint16_t strength);
+
+    struct SpeakerAngle {
+        /** Speaker channel mask */
+        bitfield<AudioChannelMask> mask;
+        // all angles are expressed in degrees and
+        // are relative to the listener.
+        int16_t azimuth; // 0 is the direction the listener faces
+                         // 180 is behind the listener
+                         // -90 is to their left
+        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(bitfield<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.
+     */
+    getVirtualizationMode() generates (Result retval, AudioDevice device);
+};
diff --git a/audio/effect/5.0/IVisualizerEffect.hal b/audio/effect/5.0/IVisualizerEffect.hal
new file mode 100644
index 0000000..38752a9
--- /dev/null
+++ b/audio/effect/5.0/IVisualizerEffect.hal
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+import IEffect;
+
+interface IVisualizerEffect extends IEffect {
+    enum CaptureSizeRange : int32_t {
+        MAX = 1024,  // maximum capture size in samples
+        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);
+
+    enum ScalingMode : int32_t {
+        // Keep in sync with SCALING_MODE_... in
+        // frameworks/base/media/java/android/media/audiofx/Visualizer.java
+        NORMALIZED = 0,
+        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);
+
+    enum MeasurementMode : int32_t {
+        // Keep in sync with MEASUREMENT_MODE_... in
+        // frameworks/base/media/java/android/media/audiofx/Visualizer.java
+        NONE = 0x0,
+        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.
+     *
+     * @return retval operation completion status.
+     * @return samples samples in 8 bit unsigned format (0 = 0x80)
+     */
+    capture() generates (Result retval, vec<uint8_t> samples);
+
+    struct Measurement {
+        MeasurementMode mode;    // discriminator
+        union Values {
+            struct PeakAndRms {
+                int32_t peakMb;  // millibels
+                int32_t rmsMb;   // millibels
+            } peakAndRms;
+        } value;
+    };
+    /**
+     * Retrieves the latest measurements. The measurements to be made
+     * are specified by 'setMeasurementMode' parameter.
+     *
+     * @return retval operation completion status.
+     * @return result measurement.
+     */
+    measure() generates (Result retval, Measurement result);
+};
diff --git a/audio/effect/5.0/types.hal b/audio/effect/5.0/types.hal
new file mode 100644
index 0000000..84e1108
--- /dev/null
+++ b/audio/effect/5.0/types.hal
@@ -0,0 +1,299 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect@5.0;
+
+import android.hardware.audio.common@5.0;
+
+enum Result : int32_t {
+    OK,
+    NOT_INITIALIZED,
+    INVALID_ARGUMENTS,
+    INVALID_STATE,
+    NOT_SUPPORTED,
+    RESULT_TOO_BIG
+};
+
+/**
+ * Effect engine capabilities/requirements flags.
+ *
+ * Definitions for flags field of effect descriptor.
+ *
+ * +----------------+--------+--------------------------------------------------
+ * | description    | bits   | values
+ * +----------------+--------+--------------------------------------------------
+ * | connection     | 0..2   | 0 insert: after track process
+ * | mode           |        | 1 auxiliary: connect to track auxiliary
+ * |                |        |  output and use send level
+ * |                |        | 2 replace: replaces track process function;
+ * |                |        |   must implement SRC, volume and mono to stereo.
+ * |                |        | 3 pre processing: applied below audio HAL on in
+ * |                |        | 4 post processing: applied below audio HAL on out
+ * |                |        | 5 - 7 reserved
+ * +----------------+--------+--------------------------------------------------
+ * | insertion      | 3..5   | 0 none
+ * | preference     |        | 1 first of the chain
+ * |                |        | 2 last of the chain
+ * |                |        | 3 exclusive (only effect in the insert chain)
+ * |                |        | 4..7 reserved
+ * +----------------+--------+--------------------------------------------------
+ * | Volume         | 6..8   | 0 none
+ * | management     |        | 1 implements volume control
+ * |                |        | 2 requires volume indication
+ * |                |        | 4 reserved
+ * +----------------+--------+--------------------------------------------------
+ * | Device         | 9..11  | 0 none
+ * | indication     |        | 1 requires device updates
+ * |                |        | 2, 4 reserved
+ * +----------------+--------+--------------------------------------------------
+ * | Sample input   | 12..13 | 1 direct: process() function or
+ * | mode           |        |   EFFECT_CMD_SET_CONFIG command must specify
+ * |                |        |   a buffer descriptor
+ * |                |        | 2 provider: process() function uses the
+ * |                |        |   bufferProvider indicated by the
+ * |                |        |   EFFECT_CMD_SET_CONFIG command to request input.
+ * |                |        |   buffers.
+ * |                |        | 3 both: both input modes are supported
+ * +----------------+--------+--------------------------------------------------
+ * | Sample output  | 14..15 | 1 direct: process() function or
+ * | mode           |        |   EFFECT_CMD_SET_CONFIG command must specify
+ * |                |        |   a buffer descriptor
+ * |                |        | 2 provider: process() function uses the
+ * |                |        |   bufferProvider indicated by the
+ * |                |        |   EFFECT_CMD_SET_CONFIG command to request output
+ * |                |        |   buffers.
+ * |                |        | 3 both: both output modes are supported
+ * +----------------+--------+--------------------------------------------------
+ * | Hardware       | 16..17 | 0 No hardware acceleration
+ * | acceleration   |        | 1 non tunneled hw acceleration: the process()
+ * |                |        |   function reads the samples, send them to HW
+ * |                |        |   accelerated effect processor, reads back
+ * |                |        |   the processed samples and returns them
+ * |                |        |   to the output buffer.
+ * |                |        | 2 tunneled hw acceleration: the process()
+ * |                |        |   function is transparent. The effect interface
+ * |                |        |   is only used to control the effect engine.
+ * |                |        |   This mode is relevant for global effects
+ * |                |        |   actually applied by the audio hardware on
+ * |                |        |   the output stream.
+ * +----------------+--------+--------------------------------------------------
+ * | Audio Mode     | 18..19 | 0 none
+ * | indication     |        | 1 requires audio mode updates
+ * |                |        | 2..3 reserved
+ * +----------------+--------+--------------------------------------------------
+ * | Audio source   | 20..21 | 0 none
+ * | indication     |        | 1 requires audio source updates
+ * |                |        | 2..3 reserved
+ * +----------------+--------+--------------------------------------------------
+ * | Effect offload | 22     | 0 The effect cannot be offloaded to an audio DSP
+ * | supported      |        | 1 The effect can be offloaded to an audio DSP
+ * +----------------+--------+--------------------------------------------------
+ * | Process        | 23     | 0 The effect implements a process function.
+ * | function       |        | 1 The effect does not implement a process
+ * | not            |        |   function: enabling the effect has no impact
+ * | implemented    |        |   on latency or CPU load.
+ * |                |        |   Effect implementations setting this flag do not
+ * |                |        |   have to implement a process function.
+ * +----------------+--------+--------------------------------------------------
+ */
+@export(name="", value_prefix="EFFECT_FLAG_")
+enum EffectFlags : int32_t {
+    // Insert mode
+    TYPE_SHIFT = 0,
+    TYPE_SIZE = 3,
+    TYPE_MASK = ((1 << TYPE_SIZE) -1) << TYPE_SHIFT,
+    TYPE_INSERT = 0 << TYPE_SHIFT,
+    TYPE_AUXILIARY = 1 << TYPE_SHIFT,
+    TYPE_REPLACE = 2 << TYPE_SHIFT,
+    TYPE_PRE_PROC = 3 << TYPE_SHIFT,
+    TYPE_POST_PROC = 4 << TYPE_SHIFT,
+
+    // Insert preference
+    INSERT_SHIFT = TYPE_SHIFT + TYPE_SIZE,
+    INSERT_SIZE = 3,
+    INSERT_MASK = ((1 << INSERT_SIZE) -1) << INSERT_SHIFT,
+    INSERT_ANY = 0 << INSERT_SHIFT,
+    INSERT_FIRST = 1 << INSERT_SHIFT,
+    INSERT_LAST = 2 << INSERT_SHIFT,
+    INSERT_EXCLUSIVE = 3 << INSERT_SHIFT,
+
+    // Volume control
+    VOLUME_SHIFT = INSERT_SHIFT + INSERT_SIZE,
+    VOLUME_SIZE = 3,
+    VOLUME_MASK = ((1 << VOLUME_SIZE) -1) << VOLUME_SHIFT,
+    VOLUME_CTRL = 1 << VOLUME_SHIFT,
+    VOLUME_IND = 2 << VOLUME_SHIFT,
+    VOLUME_NONE = 0 << VOLUME_SHIFT,
+
+    // Device indication
+    DEVICE_SHIFT = VOLUME_SHIFT + VOLUME_SIZE,
+    DEVICE_SIZE = 3,
+    DEVICE_MASK = ((1 << DEVICE_SIZE) -1) << DEVICE_SHIFT,
+    DEVICE_IND = 1 << DEVICE_SHIFT,
+    DEVICE_NONE = 0 << DEVICE_SHIFT,
+
+    // Sample input modes
+    INPUT_SHIFT = DEVICE_SHIFT + DEVICE_SIZE,
+    INPUT_SIZE = 2,
+    INPUT_MASK = ((1 << INPUT_SIZE) -1) << INPUT_SHIFT,
+    INPUT_DIRECT = 1 << INPUT_SHIFT,
+    INPUT_PROVIDER = 2 << INPUT_SHIFT,
+    INPUT_BOTH = 3 << INPUT_SHIFT,
+
+    // Sample output modes
+    OUTPUT_SHIFT = INPUT_SHIFT + INPUT_SIZE,
+    OUTPUT_SIZE = 2,
+    OUTPUT_MASK = ((1 << OUTPUT_SIZE) -1) << OUTPUT_SHIFT,
+    OUTPUT_DIRECT = 1 << OUTPUT_SHIFT,
+    OUTPUT_PROVIDER = 2 << OUTPUT_SHIFT,
+    OUTPUT_BOTH = 3 << OUTPUT_SHIFT,
+
+    // Hardware acceleration mode
+    HW_ACC_SHIFT = OUTPUT_SHIFT + OUTPUT_SIZE,
+    HW_ACC_SIZE = 2,
+    HW_ACC_MASK = ((1 << HW_ACC_SIZE) -1) << HW_ACC_SHIFT,
+    HW_ACC_SIMPLE = 1 << HW_ACC_SHIFT,
+    HW_ACC_TUNNEL = 2 << HW_ACC_SHIFT,
+
+    // Audio mode indication
+    AUDIO_MODE_SHIFT = HW_ACC_SHIFT + HW_ACC_SIZE,
+    AUDIO_MODE_SIZE = 2,
+    AUDIO_MODE_MASK = ((1 << AUDIO_MODE_SIZE) -1) << AUDIO_MODE_SHIFT,
+    AUDIO_MODE_IND = 1 << AUDIO_MODE_SHIFT,
+    AUDIO_MODE_NONE = 0 << AUDIO_MODE_SHIFT,
+
+    // Audio source indication
+    AUDIO_SOURCE_SHIFT = AUDIO_MODE_SHIFT + AUDIO_MODE_SIZE,
+    AUDIO_SOURCE_SIZE = 2,
+    AUDIO_SOURCE_MASK = ((1 << AUDIO_SOURCE_SIZE) -1) << AUDIO_SOURCE_SHIFT,
+    AUDIO_SOURCE_IND = 1 << AUDIO_SOURCE_SHIFT,
+    AUDIO_SOURCE_NONE = 0 << AUDIO_SOURCE_SHIFT,
+
+    // Effect offload indication
+    OFFLOAD_SHIFT = AUDIO_SOURCE_SHIFT + AUDIO_SOURCE_SIZE,
+    OFFLOAD_SIZE = 1,
+    OFFLOAD_MASK = ((1 << OFFLOAD_SIZE) -1) << OFFLOAD_SHIFT,
+    OFFLOAD_SUPPORTED = 1 << OFFLOAD_SHIFT,
+
+    // Effect has no process indication
+    NO_PROCESS_SHIFT = OFFLOAD_SHIFT + OFFLOAD_SIZE,
+    NO_PROCESS_SIZE = 1,
+    NO_PROCESS_MASK = ((1 << NO_PROCESS_SIZE) -1) << NO_PROCESS_SHIFT,
+    NO_PROCESS = 1 << NO_PROCESS_SHIFT
+};
+
+/**
+ * The effect descriptor contains necessary information to facilitate the
+ * enumeration of the effect engines present in a library.
+ */
+struct EffectDescriptor {
+    Uuid type;                   // UUID of to the OpenSL ES interface implemented
+                                 // by this effect
+    Uuid uuid;                   // UUID for this particular implementation
+    bitfield<EffectFlags> flags; // effect engine capabilities/requirements flags
+    uint16_t cpuLoad;            // CPU load indication expressed in 0.1 MIPS units
+                                 // as estimated on an ARM9E core (ARMv5TE) with 0 WS
+    uint16_t memoryUsage;        // data memory usage expressed in KB and includes
+                                 // only dynamically allocated memory
+    uint8_t[64] name;            // human readable effect name
+    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.:
+ * Stereo: L, R; 5.1: FL, FR, FC, LFE, BL, BR.
+ *
+ * The buffer size is expressed in frame count, a frame being composed of
+ * samples for all channels at a given time. Frame size for unspecified format
+ * (AUDIO_FORMAT_OTHER) is 8 bit by definition.
+ */
+struct AudioBuffer {
+    uint64_t id;
+    uint32_t frameCount;
+    memory data;
+};
+
+@export(name="effect_buffer_access_e", value_prefix="EFFECT_BUFFER_")
+enum EffectBufferAccess : int32_t {
+    ACCESS_WRITE,
+    ACCESS_READ,
+    ACCESS_ACCUMULATE
+};
+
+/**
+ * Determines what fields of EffectBufferConfig need to be considered.
+ */
+@export(name="", value_prefix="EFFECT_CONFIG_")
+enum EffectConfigParameters : int32_t {
+    BUFFER = 0x0001,    // buffer field
+    SMP_RATE = 0x0002,  // samplingRate
+    CHANNELS = 0x0004,  // channels
+    FORMAT = 0x0008,    // format
+    ACC_MODE = 0x0010,  // accessMode
+    // Note that the 2.0 ALL have been moved to an helper function
+};
+
+/**
+ * The buffer config structure specifies the input or output audio format
+ * to be used by the effect engine.
+ */
+struct EffectBufferConfig {
+    AudioBuffer buffer;
+    uint32_t samplingRateHz;
+    bitfield<AudioChannelMask> channels;
+    AudioFormat format;
+    EffectBufferAccess accessMode;
+    bitfield<EffectConfigParameters> mask;
+};
+
+struct EffectConfig {
+    EffectBufferConfig inputCfg;
+    EffectBufferConfig outputCfg;
+};
+
+@export(name="effect_feature_e", value_prefix="EFFECT_FEATURE_")
+enum EffectFeature : int32_t {
+    AUX_CHANNELS, // supports auxiliary channels
+                  // (e.g. dual mic noise suppressor)
+    CNT
+};
+
+struct EffectAuxChannelsConfig {
+    bitfield<AudioChannelMask> mainChannels;  // channel mask for main channels
+    bitfield<AudioChannelMask> auxChannels;   // channel mask for auxiliary channels
+};
+
+struct EffectOffloadParameter {
+    bool isOffload;          // true if the playback thread the effect
+                             // is attached to is offloaded
+    AudioIoHandle ioHandle;  // io handle of the playback thread
+                             // the effect is attached to
+};
+
+/**
+ * The message queue flags used to synchronize reads and writes from
+ * the status message queue used by effects.
+ */
+enum MessageQueueFlagBits : uint32_t {
+    DONE_PROCESSING = 1 << 0,
+    REQUEST_PROCESS = 1 << 1,
+    REQUEST_PROCESS_REVERSE = 1 << 2,
+    REQUEST_QUIT = 1 << 3,
+    REQUEST_PROCESS_ALL =
+        REQUEST_PROCESS | REQUEST_PROCESS_REVERSE | REQUEST_QUIT
+};
diff --git a/audio/effect/5.0/xml/audio_effects_conf.xsd b/audio/effect/5.0/xml/audio_effects_conf.xsd
new file mode 120000
index 0000000..9d85fa7
--- /dev/null
+++ b/audio/effect/5.0/xml/audio_effects_conf.xsd
@@ -0,0 +1 @@
+../../2.0/xml/audio_effects_conf.xsd
\ No newline at end of file
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.impl.h b/audio/effect/all-versions/default/AcousticEchoCancelerEffect.cpp
similarity index 94%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.impl.h
rename to audio/effect/all-versions/default/AcousticEchoCancelerEffect.cpp
index 8ad80a2..0b60622 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.impl.h
+++ b/audio/effect/all-versions/default/AcousticEchoCancelerEffect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "AEC_Effect_HAL"
+
+#include "AcousticEchoCancelerEffect.h"
 
 #include <android/log.h>
 #include <system/audio_effects/effect_aec.h>
@@ -25,7 +27,7 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 AcousticEchoCancelerEffect::AcousticEchoCancelerEffect(effect_handle_t handle)
@@ -33,7 +35,7 @@
 
 AcousticEchoCancelerEffect::~AcousticEchoCancelerEffect() {}
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> AcousticEchoCancelerEffect::init() {
     return mEffect->init();
 }
@@ -163,7 +165,7 @@
     return mEffect->close();
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IAcousticEchoCancelerEffect
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IAcousticEchoCancelerEffect
 // follow.
 Return<Result> AcousticEchoCancelerEffect::setEchoDelay(uint32_t echoDelayMs) {
     return mEffect->setParam(AEC_PARAM_ECHO_DELAY, echoDelayMs);
@@ -174,7 +176,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.h b/audio/effect/all-versions/default/AcousticEchoCancelerEffect.h
similarity index 85%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.h
rename to audio/effect/all-versions/default/AcousticEchoCancelerEffect.h
index 852cb3f..c18f88b 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.h
+++ b/audio/effect/all-versions/default/AcousticEchoCancelerEffect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_ACOUSTICECHOCANCELEREFFECT_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_ACOUSTICECHOCANCELEREFFECT_H
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IAcousticEchoCancelerEffect.h)
+
+#include "Effect.h"
 
 #include <hidl/Status.h>
 
@@ -26,21 +31,21 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IAcousticEchoCancelerEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::effect::CPP_VERSION::IAcousticEchoCancelerEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct AcousticEchoCancelerEffect : public IAcousticEchoCancelerEffect {
     explicit AcousticEchoCancelerEffect(effect_handle_t handle);
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
     Return<Result> setConfig(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
@@ -85,7 +90,7 @@
     Return<Result> close() override;
 
     // Methods from
-    // ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IAcousticEchoCancelerEffect follow.
+    // ::android::hardware::audio::effect::CPP_VERSION::IAcousticEchoCancelerEffect follow.
     Return<Result> setEchoDelay(uint32_t echoDelayMs) override;
     Return<void> getEchoDelay(getEchoDelay_cb _hidl_cb) override;
 
@@ -96,8 +101,10 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_ACOUSTICECHOCANCELEREFFECT_H
diff --git a/audio/effect/all-versions/default/Android.bp b/audio/effect/all-versions/default/Android.bp
index ed2a093..f23a463 100644
--- a/audio/effect/all-versions/default/Android.bp
+++ b/audio/effect/all-versions/default/Android.bp
@@ -1,10 +1,25 @@
-cc_library_headers {
-    name: "android.hardware.audio.effect@all-versions-impl",
+cc_defaults {
+    name: "android.hardware.audio.effect-impl_default",
     defaults: ["hidl_defaults"],
     vendor: true,
     relative_install_path: "hw",
-
-    export_include_dirs: ["include"],
+    srcs: [
+        "AcousticEchoCancelerEffect.cpp",
+        "AudioBufferManager.cpp",
+        "AutomaticGainControlEffect.cpp",
+        "BassBoostEffect.cpp",
+        "Conversions.cpp",
+        "DownmixEffect.cpp",
+        "Effect.cpp",
+        "EffectsFactory.cpp",
+        "EnvironmentalReverbEffect.cpp",
+        "EqualizerEffect.cpp",
+        "LoudnessEnhancerEffect.cpp",
+        "NoiseSuppressionEffect.cpp",
+        "PresetReverbEffect.cpp",
+        "VirtualizerEffect.cpp",
+        "VisualizerEffect.cpp",
+    ],
 
     shared_libs: [
         "libbase",
@@ -21,11 +36,59 @@
     ],
 
     header_libs: [
+        "android.hardware.audio.common.util@all-versions",
         "libaudio_system_headers",
         "libaudioclient_headers",
         "libeffects_headers",
         "libhardware_headers",
         "libmedia_headers",
-        "android.hardware.audio.common.util@all-versions",
     ],
 }
+
+cc_library_shared {
+    name: "android.hardware.audio.effect@2.0-impl",
+    defaults: ["android.hardware.audio.effect-impl_default"],
+    shared_libs: [
+        "android.hardware.audio.common@2.0",
+        "android.hardware.audio.common@2.0-util",
+        "android.hardware.audio.effect@2.0",
+    ],
+
+    cflags: [
+        "-DMAJOR_VERSION=2",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
+
+cc_library_shared {
+    name: "android.hardware.audio.effect@4.0-impl",
+    defaults: ["android.hardware.audio.effect-impl_default"],
+    shared_libs: [
+        "android.hardware.audio.common@4.0",
+        "android.hardware.audio.common@4.0-util",
+        "android.hardware.audio.effect@4.0",
+    ],
+
+    cflags: [
+        "-DMAJOR_VERSION=4",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
+
+cc_library_shared {
+    name: "android.hardware.audio.effect@5.0-impl",
+    defaults: ["android.hardware.audio.effect-impl_default"],
+    shared_libs: [
+        "android.hardware.audio.common@5.0",
+        "android.hardware.audio.common@5.0-util",
+        "android.hardware.audio.effect@5.0",
+    ],
+
+    cflags: [
+        "-DMAJOR_VERSION=5",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AudioBufferManager.impl.h b/audio/effect/all-versions/default/AudioBufferManager.cpp
similarity index 93%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/AudioBufferManager.impl.h
rename to audio/effect/all-versions/default/AudioBufferManager.cpp
index 71ccd2d..9a638fd 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/AudioBufferManager.impl.h
+++ b/audio/effect/all-versions/default/AudioBufferManager.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#include "AudioBufferManager.h"
 
 #include <atomic>
 
@@ -53,7 +53,7 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 AudioBufferWrapper::AudioBufferWrapper(const AudioBuffer& buffer)
@@ -83,7 +83,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AudioBufferManager.h b/audio/effect/all-versions/default/AudioBufferManager.h
similarity index 75%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/AudioBufferManager.h
rename to audio/effect/all-versions/default/AudioBufferManager.h
index 34dea2d..8b956cd 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/AudioBufferManager.h
+++ b/audio/effect/all-versions/default/AudioBufferManager.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_AUDIO_BUFFER_MANAGER_H_
+#define ANDROID_HARDWARE_AUDIO_EFFECT_AUDIO_BUFFER_MANAGER_H_
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/types.h)
 
 #include <mutex>
 
@@ -24,14 +27,14 @@
 #include <utils/RefBase.h>
 #include <utils/Singleton.h>
 
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer;
+using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
 using ::android::hidl::memory::V1_0::IMemory;
 
 namespace android {
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 class AudioBufferWrapper : public RefBase {
@@ -51,13 +54,13 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
 
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::implementation::AudioBufferWrapper;
+using ::android::hardware::audio::effect::CPP_VERSION::implementation::AudioBufferWrapper;
 
 namespace android {
 
@@ -67,7 +70,7 @@
     bool wrap(const AudioBuffer& buffer, sp<AudioBufferWrapper>* wrapper);
 
    private:
-    friend class hardware::audio::effect::AUDIO_HAL_VERSION::implementation::AudioBufferWrapper;
+    friend class hardware::audio::effect::CPP_VERSION::implementation::AudioBufferWrapper;
 
     // Called by AudioBufferWrapper.
     void removeEntry(uint64_t id);
@@ -77,3 +80,5 @@
 };
 
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_AUDIO_BUFFER_MANAGER_H_
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.impl.h b/audio/effect/all-versions/default/AutomaticGainControlEffect.cpp
similarity index 95%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.impl.h
rename to audio/effect/all-versions/default/AutomaticGainControlEffect.cpp
index e2e751e..651dd1b 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.impl.h
+++ b/audio/effect/all-versions/default/AutomaticGainControlEffect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "AGC_Effect_HAL"
+
+#include "AutomaticGainControlEffect.h"
 
 #include <android/log.h>
 
@@ -24,7 +26,7 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 AutomaticGainControlEffect::AutomaticGainControlEffect(effect_handle_t handle)
@@ -46,7 +48,7 @@
     halProperties->limiterEnabled = properties.limiterEnabled;
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> AutomaticGainControlEffect::init() {
     return mEffect->init();
 }
@@ -176,7 +178,7 @@
     return mEffect->close();
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IAutomaticGainControlEffect
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IAutomaticGainControlEffect
 // follow.
 Return<Result> AutomaticGainControlEffect::setTargetLevel(int16_t targetLevelMb) {
     return mEffect->setParam(AGC_PARAM_TARGET_LEVEL, targetLevelMb);
@@ -219,7 +221,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.h b/audio/effect/all-versions/default/AutomaticGainControlEffect.h
similarity index 87%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.h
rename to audio/effect/all-versions/default/AutomaticGainControlEffect.h
index 5ac43eb..a281b1d 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.h
+++ b/audio/effect/all-versions/default/AutomaticGainControlEffect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_AUTOMATICGAINCONTROLEFFECT_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_AUTOMATICGAINCONTROLEFFECT_H
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IAutomaticGainControlEffect.h)
+
+#include "Effect.h"
 
 #include <system/audio_effects/effect_agc.h>
 
@@ -28,21 +33,21 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IAutomaticGainControlEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::effect::CPP_VERSION::IAutomaticGainControlEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct AutomaticGainControlEffect : public IAutomaticGainControlEffect {
     explicit AutomaticGainControlEffect(effect_handle_t handle);
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
     Return<Result> setConfig(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
@@ -87,7 +92,7 @@
     Return<Result> close() override;
 
     // Methods from
-    // ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IAutomaticGainControlEffect follow.
+    // ::android::hardware::audio::effect::CPP_VERSION::IAutomaticGainControlEffect follow.
     Return<Result> setTargetLevel(int16_t targetLevelMb) override;
     Return<void> getTargetLevel(getTargetLevel_cb _hidl_cb) override;
     Return<Result> setCompGain(int16_t compGainMb) override;
@@ -110,8 +115,10 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_AUTOMATICGAINCONTROLEFFECT_H
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.impl.h b/audio/effect/all-versions/default/BassBoostEffect.cpp
similarity index 93%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.impl.h
rename to audio/effect/all-versions/default/BassBoostEffect.cpp
index 7bcb4a3..6f7763d 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.impl.h
+++ b/audio/effect/all-versions/default/BassBoostEffect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "BassBoost_HAL"
+
+#include "BassBoostEffect.h"
 
 #include <android/log.h>
 #include <system/audio_effects/effect_bassboost.h>
@@ -25,14 +27,14 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 BassBoostEffect::BassBoostEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
 
 BassBoostEffect::~BassBoostEffect() {}
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> BassBoostEffect::init() {
     return mEffect->init();
 }
@@ -159,7 +161,7 @@
     return mEffect->close();
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IBassBoostEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IBassBoostEffect follow.
 Return<void> BassBoostEffect::isStrengthSupported(isStrengthSupported_cb _hidl_cb) {
     return mEffect->getIntegerParam(BASSBOOST_PARAM_STRENGTH_SUPPORTED, _hidl_cb);
 }
@@ -173,7 +175,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.h b/audio/effect/all-versions/default/BassBoostEffect.h
similarity index 85%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.h
rename to audio/effect/all-versions/default/BassBoostEffect.h
index 29173dd..a184ac2 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.h
+++ b/audio/effect/all-versions/default/BassBoostEffect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,14 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_BASSBOOSTEFFECT_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_BASSBOOSTEFFECT_H
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IBassBoostEffect.h)
+
+#include <hidl/MQDescriptor.h>
+
+#include "Effect.h"
 
 #include <hidl/Status.h>
 
@@ -26,21 +33,21 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IBassBoostEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::effect::CPP_VERSION::IBassBoostEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct BassBoostEffect : public IBassBoostEffect {
     explicit BassBoostEffect(effect_handle_t handle);
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
     Return<Result> setConfig(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
@@ -84,7 +91,7 @@
                                               const hidl_vec<uint8_t>& configData) override;
     Return<Result> close() override;
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IBassBoostEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IBassBoostEffect follow.
     Return<void> isStrengthSupported(isStrengthSupported_cb _hidl_cb) override;
     Return<Result> setStrength(uint16_t strength) override;
     Return<void> getStrength(getStrength_cb _hidl_cb) override;
@@ -96,8 +103,10 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_BASSBOOSTEFFECT_H
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/Conversions.impl.h b/audio/effect/all-versions/default/Conversions.cpp
similarity index 80%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/Conversions.impl.h
rename to audio/effect/all-versions/default/Conversions.cpp
index de67d89..50b0562 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/Conversions.impl.h
+++ b/audio/effect/all-versions/default/Conversions.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,28 +14,31 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#include "Conversions.h"
+#include "HidlUtils.h"
+
+using ::android::hardware::audio::common::CPP_VERSION::HidlUtils;
 
 #include <memory.h>
 #include <stdio.h>
 
 #include <common/all-versions/VersionUtils.h>
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::HidlUtils;
-using ::android::hardware::audio::common::utils::mkEnumConverter;
+using ::android::hardware::audio::common::CPP_VERSION::HidlUtils;
+using ::android::hardware::audio::common::utils::EnumBitfield;
 
 namespace android {
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 void effectDescriptorFromHal(const effect_descriptor_t& halDescriptor,
                              EffectDescriptor* descriptor) {
     HidlUtils::uuidFromHal(halDescriptor.type, &descriptor->type);
     HidlUtils::uuidFromHal(halDescriptor.uuid, &descriptor->uuid);
-    descriptor->flags = mkEnumConverter<EffectFlags>(halDescriptor.flags);
+    descriptor->flags = EnumBitfield<EffectFlags>(halDescriptor.flags);
     descriptor->cpuLoad = halDescriptor.cpuLoad;
     descriptor->memoryUsage = halDescriptor.memoryUsage;
     memcpy(descriptor->name.data(), halDescriptor.name, descriptor->name.size());
@@ -52,7 +55,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/Conversions.h b/audio/effect/all-versions/default/Conversions.h
similarity index 71%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/Conversions.h
rename to audio/effect/all-versions/default/Conversions.h
index 3f9317f..75aab24 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/Conversions.h
+++ b/audio/effect/all-versions/default/Conversions.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_CONVERSIONS_H_
+#define ANDROID_HARDWARE_AUDIO_EFFECT_CONVERSIONS_H_
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/types.h)
 
 #include <string>
 
@@ -24,18 +27,20 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
 
 void effectDescriptorFromHal(const effect_descriptor_t& halDescriptor,
                              EffectDescriptor* descriptor);
 std::string uuidToString(const effect_uuid_t& halUuid);
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_CONVERSIONS_H_
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.impl.h b/audio/effect/all-versions/default/DownmixEffect.cpp
similarity index 93%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.impl.h
rename to audio/effect/all-versions/default/DownmixEffect.cpp
index abef10e..94da70e 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.impl.h
+++ b/audio/effect/all-versions/default/DownmixEffect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "Downmix_HAL"
+
+#include "DownmixEffect.h"
 
 #include <android/log.h>
 #include <system/audio_effects/effect_downmix.h>
@@ -25,14 +27,14 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 DownmixEffect::DownmixEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
 
 DownmixEffect::~DownmixEffect() {}
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> DownmixEffect::init() {
     return mEffect->init();
 }
@@ -159,7 +161,7 @@
     return mEffect->close();
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IDownmixEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IDownmixEffect follow.
 Return<Result> DownmixEffect::setType(IDownmixEffect::Type preset) {
     return mEffect->setParam(DOWNMIX_PARAM_TYPE, static_cast<downmix_type_t>(preset));
 }
@@ -172,7 +174,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.h b/audio/effect/all-versions/default/DownmixEffect.h
similarity index 86%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.h
rename to audio/effect/all-versions/default/DownmixEffect.h
index 3e3aa78..6d34c28 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.h
+++ b/audio/effect/all-versions/default/DownmixEffect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_DOWNMIXEFFECT_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_DOWNMIXEFFECT_H
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IDownmixEffect.h)
+
+#include "Effect.h"
 
 #include <hidl/Status.h>
 
@@ -26,21 +31,21 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IDownmixEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::effect::CPP_VERSION::IDownmixEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct DownmixEffect : public IDownmixEffect {
     explicit DownmixEffect(effect_handle_t handle);
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
     Return<Result> setConfig(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
@@ -84,7 +89,7 @@
                                               const hidl_vec<uint8_t>& configData) override;
     Return<Result> close() override;
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IDownmixEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IDownmixEffect follow.
     Return<Result> setType(IDownmixEffect::Type preset) override;
     Return<void> getType(getType_cb _hidl_cb) override;
 
@@ -95,8 +100,10 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_DOWNMIXEFFECT_H
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.impl.h b/audio/effect/all-versions/default/Effect.cpp
similarity index 97%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/Effect.impl.h
rename to audio/effect/all-versions/default/Effect.cpp
index 61c9805..3e5148f 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.impl.h
+++ b/audio/effect/all-versions/default/Effect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,14 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#include <memory.h>
+
+#define LOG_TAG "EffectHAL"
+#define ATRACE_TAG ATRACE_TAG_AUDIO
+
+#include "Conversions.h"
+#include "Effect.h"
+#include "common/all-versions/default/EffectMap.h"
 
 #include <memory.h>
 
@@ -30,13 +37,13 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioChannelBitfield;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::MessageQueueFlagBits;
+using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
+using ::android::hardware::audio::common::CPP_VERSION::AudioFormat;
+using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield;
+using ::android::hardware::audio::effect::CPP_VERSION::MessageQueueFlagBits;
 
 namespace {
 
@@ -479,7 +486,7 @@
                                       &halParamBuffer[0]);
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> Effect::init() {
     return sendCommandReturningStatus(EFFECT_CMD_INIT, "INIT");
 }
@@ -707,7 +714,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.h b/audio/effect/all-versions/default/Effect.h
similarity index 88%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/Effect.h
rename to audio/effect/all-versions/default/Effect.h
index b546e0e..f6a12d9 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.h
+++ b/audio/effect/all-versions/default/Effect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_EFFECT_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_EFFECT_H
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IEffect.h)
+
+#include "AudioBufferManager.h"
 
 #include <atomic>
 #include <memory>
@@ -34,28 +39,28 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::Uuid;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioDeviceBitfield;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectFeature;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::common::CPP_VERSION::Uuid;
+using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioDeviceBitfield;
+using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectFeature;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct Effect : public IEffect {
     typedef MessageQueue<Result, kSynchronizedReadWrite> StatusMQ;
@@ -64,7 +69,7 @@
 
     explicit Effect(effect_handle_t handle);
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
     Return<Result> setConfig(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
@@ -234,8 +239,10 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_EFFECT_H
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.impl.h b/audio/effect/all-versions/default/EffectsFactory.cpp
similarity index 88%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.impl.h
rename to audio/effect/all-versions/default/EffectsFactory.cpp
index f3256f1..d2d8a46 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.impl.h
+++ b/audio/effect/all-versions/default/EffectsFactory.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,25 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "EffectFactoryHAL"
+#include "EffectsFactory.h"
+#include "AcousticEchoCancelerEffect.h"
+#include "AutomaticGainControlEffect.h"
+#include "BassBoostEffect.h"
+#include "Conversions.h"
+#include "DownmixEffect.h"
+#include "Effect.h"
+#include "EnvironmentalReverbEffect.h"
+#include "EqualizerEffect.h"
+#include "HidlUtils.h"
+#include "LoudnessEnhancerEffect.h"
+#include "NoiseSuppressionEffect.h"
+#include "PresetReverbEffect.h"
+#include "VirtualizerEffect.h"
+#include "VisualizerEffect.h"
+#include "common/all-versions/default/EffectMap.h"
+
+using ::android::hardware::audio::common::CPP_VERSION::HidlUtils;
 
 #include <android/log.h>
 #include <media/EffectsFactoryApi.h>
@@ -30,13 +48,13 @@
 #include <system/audio_effects/effect_virtualizer.h>
 #include <system/audio_effects/effect_visualizer.h>
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::HidlUtils;
+using ::android::hardware::audio::common::CPP_VERSION::HidlUtils;
 
 namespace android {
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 // static
@@ -69,7 +87,7 @@
     return new Effect(handle);
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectsFactory follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffectsFactory follow.
 Return<void> EffectsFactory::getAllDescriptors(getAllDescriptors_cb _hidl_cb) {
     Result retval(Result::OK);
     hidl_vec<EffectDescriptor> result;
@@ -189,7 +207,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.h b/audio/effect/all-versions/default/EffectsFactory.h
similarity index 65%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.h
rename to audio/effect/all-versions/default/EffectsFactory.h
index 526abbb8..0cbfaa2 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.h
+++ b/audio/effect/all-versions/default/EffectsFactory.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,14 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_EFFECTSFACTORY_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_EFFECTSFACTORY_H
+
+#include <system/audio_effect.h>
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IEffectsFactory.h)
+
+#include <hidl/MQDescriptor.h>
 
 #include <hardware/audio_effect.h>
 #include <system/audio_effect.h>
@@ -26,27 +33,28 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::Uuid;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectsFactory;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::Uuid;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffectsFactory;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct EffectsFactory : public IEffectsFactory {
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectsFactory follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffectsFactory follow.
     Return<void> getAllDescriptors(getAllDescriptors_cb _hidl_cb) override;
     Return<void> getDescriptor(const Uuid& uid, getDescriptor_cb _hidl_cb) override;
     Return<void> createEffect(const Uuid& uid, int32_t session, int32_t ioHandle,
                               createEffect_cb _hidl_cb) override;
-    Return<void> debugDump(const hidl_handle& fd); //< in V2_0::IEffectsFactory only, alias of debug
+    Return<void> debugDump(
+        const hidl_handle& fd);  //< in CPP_VERSION::IEffectsFactory only, alias of debug
     Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
 
    private:
@@ -57,8 +65,10 @@
 extern "C" IEffectsFactory* HIDL_FETCH_IEffectsFactory(const char* name);
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_EFFECTSFACTORY_H
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.impl.h b/audio/effect/all-versions/default/EnvironmentalReverbEffect.cpp
similarity index 96%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.impl.h
rename to audio/effect/all-versions/default/EnvironmentalReverbEffect.cpp
index 39a4092..1ade7b8 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.impl.h
+++ b/audio/effect/all-versions/default/EnvironmentalReverbEffect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "EnvReverb_HAL"
+#include <android/log.h>
+
+#include "EnvironmentalReverbEffect.h"
 
 #include <android/log.h>
 
@@ -24,7 +27,7 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 EnvironmentalReverbEffect::EnvironmentalReverbEffect(effect_handle_t handle)
@@ -60,7 +63,7 @@
     halProperties->density = properties.density;
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> EnvironmentalReverbEffect::init() {
     return mEffect->init();
 }
@@ -190,7 +193,7 @@
     return mEffect->close();
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEnvironmentalReverbEffect
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEnvironmentalReverbEffect
 // follow.
 Return<Result> EnvironmentalReverbEffect::setBypass(bool bypass) {
     return mEffect->setParam(REVERB_PARAM_BYPASS, bypass);
@@ -297,7 +300,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.h b/audio/effect/all-versions/default/EnvironmentalReverbEffect.h
similarity index 80%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.h
rename to audio/effect/all-versions/default/EnvironmentalReverbEffect.h
index d2f8cc3..7e6597b 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.h
+++ b/audio/effect/all-versions/default/EnvironmentalReverbEffect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,14 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_ENVIRONMENTALREVERBEFFECT_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_ENVIRONMENTALREVERBEFFECT_H
+
+#include <system/audio_effects/effect_environmentalreverb.h>
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IEnvironmentalReverbEffect.h)
+
+#include "Effect.h"
 
 #include <system/audio_effects/effect_environmentalreverb.h>
 
@@ -28,31 +35,31 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEnvironmentalReverbEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback;
+using ::android::hardware::audio::effect::CPP_VERSION::IEnvironmentalReverbEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect {
     explicit EnvironmentalReverbEffect(effect_handle_t handle);
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
     Return<Result> setConfig(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
@@ -97,7 +104,7 @@
     Return<Result> close() override;
 
     // Methods from
-    // ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEnvironmentalReverbEffect follow.
+    // ::android::hardware::audio::effect::CPP_VERSION::IEnvironmentalReverbEffect follow.
     Return<Result> setBypass(bool bypass) override;
     Return<void> getBypass(getBypass_cb _hidl_cb) override;
     Return<Result> setRoomLevel(int16_t roomLevel) override;
@@ -136,8 +143,10 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_ENVIRONMENTALREVERBEFFECT_H
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.impl.h b/audio/effect/all-versions/default/EqualizerEffect.cpp
similarity index 96%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.impl.h
rename to audio/effect/all-versions/default/EqualizerEffect.cpp
index db6bed8..f6177b7 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.impl.h
+++ b/audio/effect/all-versions/default/EqualizerEffect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "Equalizer_HAL"
+
+#include "EqualizerEffect.h"
 
 #include <memory.h>
 
@@ -26,7 +28,7 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 EqualizerEffect::EqualizerEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
@@ -55,7 +57,7 @@
     return halBuffer;
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> EqualizerEffect::init() {
     return mEffect->init();
 }
@@ -182,7 +184,7 @@
     return mEffect->close();
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEqualizerEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect follow.
 Return<void> EqualizerEffect::getNumBands(getNumBands_cb _hidl_cb) {
     return mEffect->getIntegerParam(EQ_PARAM_NUM_BANDS, _hidl_cb);
 }
@@ -285,7 +287,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.h b/audio/effect/all-versions/default/EqualizerEffect.h
similarity index 79%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.h
rename to audio/effect/all-versions/default/EqualizerEffect.h
index de52052..5e1e2b9 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.h
+++ b/audio/effect/all-versions/default/EqualizerEffect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_EQUALIZEREFFECT_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_EQUALIZEREFFECT_H
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IEqualizerEffect.h)
+
+#include "Effect.h"
 
 #include <vector>
 
@@ -30,31 +35,31 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEqualizerEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback;
+using ::android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct EqualizerEffect : public IEqualizerEffect {
     explicit EqualizerEffect(effect_handle_t handle);
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
     Return<Result> setConfig(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
@@ -98,7 +103,7 @@
                                               const hidl_vec<uint8_t>& configData) override;
     Return<Result> close() override;
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEqualizerEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect follow.
     Return<void> getNumBands(getNumBands_cb _hidl_cb) override;
     Return<void> getLevelRange(getLevelRange_cb _hidl_cb) override;
     Return<Result> setBandLevel(uint16_t band, int16_t level) override;
@@ -124,8 +129,10 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_EQUALIZEREFFECT_H
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.impl.h b/audio/effect/all-versions/default/LoudnessEnhancerEffect.cpp
similarity index 94%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.impl.h
rename to audio/effect/all-versions/default/LoudnessEnhancerEffect.cpp
index 88210e9..6918bdf 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.impl.h
+++ b/audio/effect/all-versions/default/LoudnessEnhancerEffect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "LoudnessEnhancer_HAL"
+
+#include "LoudnessEnhancerEffect.h"
 
 #include <system/audio_effects/effect_loudnessenhancer.h>
 
@@ -27,7 +29,7 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 LoudnessEnhancerEffect::LoudnessEnhancerEffect(effect_handle_t handle)
@@ -35,7 +37,7 @@
 
 LoudnessEnhancerEffect::~LoudnessEnhancerEffect() {}
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> LoudnessEnhancerEffect::init() {
     return mEffect->init();
 }
@@ -162,7 +164,7 @@
     return mEffect->close();
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::ILoudnessEnhancerEffect
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::ILoudnessEnhancerEffect
 // follow.
 Return<Result> LoudnessEnhancerEffect::setTargetGain(int32_t targetGainMb) {
     return mEffect->setParam(LOUDNESS_ENHANCER_DEFAULT_TARGET_GAIN_MB, targetGainMb);
@@ -182,7 +184,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.h b/audio/effect/all-versions/default/LoudnessEnhancerEffect.h
similarity index 75%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.h
rename to audio/effect/all-versions/default/LoudnessEnhancerEffect.h
index b59b077..6eb8a8c 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.h
+++ b/audio/effect/all-versions/default/LoudnessEnhancerEffect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_LOUDNESSENHANCEREFFECT_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_LOUDNESSENHANCEREFFECT_H
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/ILoudnessEnhancerEffect.h)
+
+#include "Effect.h"
 
 #include <hidl/Status.h>
 
@@ -26,31 +31,31 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::ILoudnessEnhancerEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback;
+using ::android::hardware::audio::effect::CPP_VERSION::ILoudnessEnhancerEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect {
     explicit LoudnessEnhancerEffect(effect_handle_t handle);
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
     Return<Result> setConfig(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
@@ -94,7 +99,7 @@
                                               const hidl_vec<uint8_t>& configData) override;
     Return<Result> close() override;
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::ILoudnessEnhancerEffect
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::ILoudnessEnhancerEffect
     // follow.
     Return<Result> setTargetGain(int32_t targetGainMb) override;
     Return<void> getTargetGain(getTargetGain_cb _hidl_cb) override;
@@ -106,8 +111,10 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_LOUDNESSENHANCEREFFECT_H
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.impl.h b/audio/effect/all-versions/default/NoiseSuppressionEffect.cpp
similarity index 95%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.impl.h
rename to audio/effect/all-versions/default/NoiseSuppressionEffect.cpp
index f32399c..4756719 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.impl.h
+++ b/audio/effect/all-versions/default/NoiseSuppressionEffect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "NS_Effect_HAL"
+
+#include "NoiseSuppressionEffect.h"
 
 #include <android/log.h>
 
@@ -24,7 +26,7 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 NoiseSuppressionEffect::NoiseSuppressionEffect(effect_handle_t handle)
@@ -44,7 +46,7 @@
     halProperties->type = static_cast<uint32_t>(properties.type);
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> NoiseSuppressionEffect::init() {
     return mEffect->init();
 }
@@ -171,7 +173,7 @@
     return mEffect->close();
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::INoiseSuppressionEffect
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::INoiseSuppressionEffect
 // follow.
 Return<Result> NoiseSuppressionEffect::setSuppressionLevel(INoiseSuppressionEffect::Level level) {
     return mEffect->setParam(NS_PARAM_LEVEL, static_cast<int32_t>(level));
@@ -212,7 +214,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.h b/audio/effect/all-versions/default/NoiseSuppressionEffect.h
similarity index 77%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.h
rename to audio/effect/all-versions/default/NoiseSuppressionEffect.h
index af1635b..af62dd1 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.h
+++ b/audio/effect/all-versions/default/NoiseSuppressionEffect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_NOISESUPPRESSIONEFFECT_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_NOISESUPPRESSIONEFFECT_H
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/INoiseSuppressionEffect.h)
+
+#include "Effect.h"
 
 #include <system/audio_effects/effect_ns.h>
 
@@ -28,31 +33,31 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::INoiseSuppressionEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback;
+using ::android::hardware::audio::effect::CPP_VERSION::INoiseSuppressionEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct NoiseSuppressionEffect : public INoiseSuppressionEffect {
     explicit NoiseSuppressionEffect(effect_handle_t handle);
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
     Return<Result> setConfig(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
@@ -96,7 +101,7 @@
                                               const hidl_vec<uint8_t>& configData) override;
     Return<Result> close() override;
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::INoiseSuppressionEffect
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::INoiseSuppressionEffect
     // follow.
     Return<Result> setSuppressionLevel(INoiseSuppressionEffect::Level level) override;
     Return<void> getSuppressionLevel(getSuppressionLevel_cb _hidl_cb) override;
@@ -118,8 +123,10 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_NOISESUPPRESSIONEFFECT_H
diff --git a/audio/effect/all-versions/OWNERS b/audio/effect/all-versions/default/OWNERS
similarity index 100%
rename from audio/effect/all-versions/OWNERS
rename to audio/effect/all-versions/default/OWNERS
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.impl.h b/audio/effect/all-versions/default/PresetReverbEffect.cpp
similarity index 93%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.impl.h
rename to audio/effect/all-versions/default/PresetReverbEffect.cpp
index eab68fb..97723f5 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.impl.h
+++ b/audio/effect/all-versions/default/PresetReverbEffect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "PresetReverb_HAL"
+
+#include "PresetReverbEffect.h"
 
 #include <android/log.h>
 #include <system/audio_effects/effect_presetreverb.h>
@@ -25,14 +27,14 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 PresetReverbEffect::PresetReverbEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
 
 PresetReverbEffect::~PresetReverbEffect() {}
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> PresetReverbEffect::init() {
     return mEffect->init();
 }
@@ -159,7 +161,7 @@
     return mEffect->close();
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IPresetReverbEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IPresetReverbEffect follow.
 Return<Result> PresetReverbEffect::setPreset(IPresetReverbEffect::Preset preset) {
     return mEffect->setParam(REVERB_PARAM_PRESET, static_cast<t_reverb_presets>(preset));
 }
@@ -172,7 +174,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.h b/audio/effect/all-versions/default/PresetReverbEffect.h
similarity index 75%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.h
rename to audio/effect/all-versions/default/PresetReverbEffect.h
index 1a91ab4..aa864b0 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.h
+++ b/audio/effect/all-versions/default/PresetReverbEffect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_PRESETREVERBEFFECT_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_PRESETREVERBEFFECT_H
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IPresetReverbEffect.h)
+
+#include "Effect.h"
 
 #include <hidl/Status.h>
 
@@ -26,31 +31,31 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IPresetReverbEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback;
+using ::android::hardware::audio::effect::CPP_VERSION::IPresetReverbEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct PresetReverbEffect : public IPresetReverbEffect {
     explicit PresetReverbEffect(effect_handle_t handle);
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
     Return<Result> setConfig(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
@@ -94,7 +99,7 @@
                                               const hidl_vec<uint8_t>& configData) override;
     Return<Result> close() override;
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IPresetReverbEffect
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IPresetReverbEffect
     // follow.
     Return<Result> setPreset(IPresetReverbEffect::Preset preset) override;
     Return<void> getPreset(getPreset_cb _hidl_cb) override;
@@ -106,8 +111,10 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_PRESETREVERBEFFECT_H
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.impl.h b/audio/effect/all-versions/default/VirtualizerEffect.cpp
similarity index 95%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.impl.h
rename to audio/effect/all-versions/default/VirtualizerEffect.cpp
index 23b09a89..4d597c7 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.impl.h
+++ b/audio/effect/all-versions/default/VirtualizerEffect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "Virtualizer_HAL"
+
+#include "VirtualizerEffect.h"
 
 #include <memory.h>
 
@@ -27,7 +29,7 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 VirtualizerEffect::VirtualizerEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
@@ -44,7 +46,7 @@
     }
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> VirtualizerEffect::init() {
     return mEffect->init();
 }
@@ -171,7 +173,7 @@
     return mEffect->close();
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IVirtualizerEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IVirtualizerEffect follow.
 Return<bool> VirtualizerEffect::isStrengthSupported() {
     bool halSupported = false;
     mEffect->getParam(VIRTUALIZER_PARAM_STRENGTH_SUPPORTED, halSupported);
@@ -224,7 +226,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.h b/audio/effect/all-versions/default/VirtualizerEffect.h
similarity index 75%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.h
rename to audio/effect/all-versions/default/VirtualizerEffect.h
index c0d5a00..87b53d6 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.h
+++ b/audio/effect/all-versions/default/VirtualizerEffect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VIRTUALIZEREFFECT_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_VIRTUALIZEREFFECT_H
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IVirtualizerEffect.h)
+
+#include "Effect.h"
 
 #include <hidl/Status.h>
 
@@ -26,33 +31,33 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioChannelBitfield;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IVirtualizerEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield;
+using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback;
+using ::android::hardware::audio::effect::CPP_VERSION::IVirtualizerEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct VirtualizerEffect : public IVirtualizerEffect {
     explicit VirtualizerEffect(effect_handle_t handle);
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
     Return<Result> setConfig(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
@@ -96,7 +101,7 @@
                                               const hidl_vec<uint8_t>& configData) override;
     Return<Result> close() override;
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IVirtualizerEffect
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IVirtualizerEffect
     // follow.
     Return<bool> isStrengthSupported() override;
     Return<Result> setStrength(uint16_t strength) override;
@@ -116,8 +121,10 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_VIRTUALIZEREFFECT_H
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.impl.h b/audio/effect/all-versions/default/VisualizerEffect.cpp
similarity index 95%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.impl.h
rename to audio/effect/all-versions/default/VisualizerEffect.cpp
index 9f2195b..77bf46b 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.impl.h
+++ b/audio/effect/all-versions/default/VisualizerEffect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#define LOG_TAG "Visualizer_HAL"
+
+#include "VisualizerEffect.h"
 
 #include <android/log.h>
 #include <system/audio_effects/effect_visualizer.h>
@@ -25,7 +27,7 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
 VisualizerEffect::VisualizerEffect(effect_handle_t handle)
@@ -33,7 +35,7 @@
 
 VisualizerEffect::~VisualizerEffect() {}
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> VisualizerEffect::init() {
     return mEffect->init();
 }
@@ -160,7 +162,7 @@
     return mEffect->close();
 }
 
-// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IVisualizerEffect follow.
+// Methods from ::android::hardware::audio::effect::CPP_VERSION::IVisualizerEffect follow.
 Return<Result> VisualizerEffect::setCaptureSize(uint16_t captureSize) {
     Result retval = mEffect->setParam(VISUALIZER_PARAM_CAPTURE_SIZE, captureSize);
     if (retval == Result::OK) {
@@ -247,7 +249,7 @@
 }
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.h b/audio/effect/all-versions/default/VisualizerEffect.h
similarity index 77%
rename from audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.h
rename to audio/effect/all-versions/default/VisualizerEffect.h
index 114d3b7..0a13a2b 100644
--- a/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.h
+++ b/audio/effect/all-versions/default/VisualizerEffect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,7 +14,12 @@
  * limitations under the License.
  */
 
-#include <common/all-versions/IncludeGuard.h>
+#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VISUALIZEREFFECT_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_VISUALIZEREFFECT_H
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IVisualizerEffect.h)
+
+#include "Effect.h"
 
 #include <hidl/Status.h>
 
@@ -26,31 +31,31 @@
 namespace hardware {
 namespace audio {
 namespace effect {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
 namespace implementation {
 
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode;
-using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IVisualizerEffect;
-using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result;
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
+using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback;
+using ::android::hardware::audio::effect::CPP_VERSION::IVisualizerEffect;
+using ::android::hardware::audio::effect::CPP_VERSION::Result;
 
 struct VisualizerEffect : public IVisualizerEffect {
     explicit VisualizerEffect(effect_handle_t handle);
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
     Return<Result> setConfig(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
@@ -94,7 +99,7 @@
                                               const hidl_vec<uint8_t>& configData) override;
     Return<Result> close() override;
 
-    // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IVisualizerEffect follow.
+    // Methods from ::android::hardware::audio::effect::CPP_VERSION::IVisualizerEffect follow.
     Return<Result> setCaptureSize(uint16_t captureSize) override;
     Return<void> getCaptureSize(getCaptureSize_cb _hidl_cb) override;
     Return<Result> setScalingMode(IVisualizerEffect::ScalingMode scalingMode) override;
@@ -115,8 +120,10 @@
 };
 
 }  // namespace implementation
-}  // namespace AUDIO_HAL_VERSION
+}  // namespace CPP_VERSION
 }  // namespace effect
 }  // namespace audio
 }  // namespace hardware
 }  // namespace android
+
+#endif  // ANDROID_HARDWARE_AUDIO_EFFECT_VISUALIZEREFFECT_H
diff --git a/audio/core/2.0/vts/OWNERS b/audio/effect/all-versions/vts/OWNERS
similarity index 98%
copy from audio/core/2.0/vts/OWNERS
copy to audio/effect/all-versions/vts/OWNERS
index 8711a9f..0ea4666 100644
--- a/audio/core/2.0/vts/OWNERS
+++ b/audio/effect/all-versions/vts/OWNERS
@@ -2,4 +2,4 @@
 krocard@google.com
 mnaganov@google.com
 yim@google.com
-zhuoyao@google.com
\ No newline at end of file
+zhuoyao@google.com
diff --git a/audio/effect/all-versions/vts/functional/Android.bp b/audio/effect/all-versions/vts/functional/Android.bp
new file mode 100644
index 0000000..88d49d8
--- /dev/null
+++ b/audio/effect/all-versions/vts/functional/Android.bp
@@ -0,0 +1,80 @@
+//
+// 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.
+//
+
+cc_defaults {
+    name: "VtsHalAudioEffectTargetTest_default",
+    defaults: ["VtsHalTargetTestDefaults"],
+    srcs: [
+        "VtsHalAudioEffectTargetTest.cpp",
+        "ValidateAudioEffectsConfiguration.cpp"
+    ],
+    static_libs: [
+        "android.hardware.audio.common.test.utility",
+        "android.hidl.allocator@1.0",
+        "android.hidl.memory@1.0",
+        "libeffectsconfig",
+        "libicuuc",
+        "libicuuc_stubdata",
+        "libxml2",
+    ],
+    header_libs: [
+        "android.hardware.audio.common.util@all-versions",
+    ],
+    test_suites: ["general-tests"],
+}
+
+cc_test {
+    name: "VtsHalAudioEffectV2_0TargetTest",
+    defaults: ["VtsHalAudioEffectTargetTest_default"],
+    static_libs: [
+        "android.hardware.audio.common@2.0",
+        "android.hardware.audio.effect@2.0",
+    ],
+    cflags: [
+        "-DMAJOR_VERSION=2",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
+
+cc_test {
+    name: "VtsHalAudioEffectV4_0TargetTest",
+    defaults: ["VtsHalAudioEffectTargetTest_default"],
+    static_libs: [
+        "android.hardware.audio.common@4.0",
+        "android.hardware.audio.effect@4.0",
+    ],
+    cflags: [
+        "-DMAJOR_VERSION=4",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
+
+cc_test {
+    name: "VtsHalAudioEffectV5_0TargetTest",
+    defaults: ["VtsHalAudioEffectTargetTest_default"],
+    static_libs: [
+        "android.hardware.audio.common@5.0",
+        "android.hardware.audio.effect@5.0",
+    ],
+    cflags: [
+        "-DMAJOR_VERSION=5",
+        "-DMINOR_VERSION=0",
+        "-include common/all-versions/VersionMacro.h",
+    ]
+}
+
diff --git a/audio/effect/4.0/vts/functional/ValidateAudioEffectsConfiguration.cpp b/audio/effect/all-versions/vts/functional/ValidateAudioEffectsConfiguration.cpp
similarity index 68%
rename from audio/effect/4.0/vts/functional/ValidateAudioEffectsConfiguration.cpp
rename to audio/effect/all-versions/vts/functional/ValidateAudioEffectsConfiguration.cpp
index 6338563..f9e4aa3 100644
--- a/audio/effect/4.0/vts/functional/ValidateAudioEffectsConfiguration.cpp
+++ b/audio/effect/all-versions/vts/functional/ValidateAudioEffectsConfiguration.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -21,12 +21,22 @@
 
 #include "utility/ValidateXml.h"
 
+// Stringify the argument.
+#define QUOTE(x) #x
+#define STRINGIFY(x) QUOTE(x)
+
 TEST(CheckConfig, audioEffectsConfigurationValidation) {
     RecordProperty("description",
                    "Verify that the effects configuration file is valid according to the schema");
     using namespace android::effectsConfig;
 
     std::vector<const char*> locations(std::begin(DEFAULT_LOCATIONS), std::end(DEFAULT_LOCATIONS));
-    EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations,
-                                            "/data/local/tmp/audio_effects_conf_V4_0.xsd");
+    const char* xsd = "/data/local/tmp/audio_effects_conf_" STRINGIFY(CPP_VERSION) ".xsd";
+#if MAJOR_VERSION == 2
+    // In V2, audio effect XML is not required. .conf is still allowed though deprecated
+    EXPECT_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations, xsd);
+#elif MAJOR_VERSION >= 4
+    // Starting with V4, audio effect XML is required
+    EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations, xsd);
+#endif
 }
diff --git a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp
new file mode 100644
index 0000000..cf7fedf
--- /dev/null
+++ b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp
@@ -0,0 +1,832 @@
+/*
+ * Copyright (C) 2018 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 "AudioEffectHidlHalTest"
+#include <android-base/logging.h>
+#include <system/audio.h>
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IEffect.h)
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IEffectsFactory.h)
+#include PATH(android/hardware/audio/effect/FILE_VERSION/IEqualizerEffect.h)
+#include PATH(android/hardware/audio/effect/FILE_VERSION/ILoudnessEnhancerEffect.h)
+#include PATH(android/hardware/audio/effect/FILE_VERSION/types.h)
+#include <android/hidl/allocator/1.0/IAllocator.h>
+#include <android/hidl/memory/1.0/IMemory.h>
+
+#include <common/all-versions/VersionUtils.h>
+
+#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
+
+using android::sp;
+using android::hardware::hidl_handle;
+using android::hardware::hidl_memory;
+using android::hardware::hidl_string;
+using android::hardware::hidl_vec;
+using android::hardware::MQDescriptorSync;
+using android::hardware::Return;
+using android::hardware::Void;
+using android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using android::hardware::audio::common::CPP_VERSION::AudioHandleConsts;
+using android::hardware::audio::common::CPP_VERSION::AudioMode;
+using android::hardware::audio::common::CPP_VERSION::AudioSource;
+using android::hardware::audio::common::CPP_VERSION::Uuid;
+using android::hardware::audio::common::utils::mkEnumBitfield;
+using android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
+using android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig;
+using android::hardware::audio::effect::CPP_VERSION::EffectBufferConfig;
+using android::hardware::audio::effect::CPP_VERSION::EffectConfig;
+using android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
+using android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter;
+using android::hardware::audio::effect::CPP_VERSION::IEffect;
+using android::hardware::audio::effect::CPP_VERSION::IEffectsFactory;
+using android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect;
+using android::hardware::audio::effect::CPP_VERSION::ILoudnessEnhancerEffect;
+using android::hardware::audio::effect::CPP_VERSION::Result;
+using android::hidl::allocator::V1_0::IAllocator;
+using android::hidl::memory::V1_0::IMemory;
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
+#endif
+
+// Test environment for Audio Effects Factory HIDL HAL.
+class AudioEffectsFactoryHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+   public:
+    // get the test environment singleton
+    static AudioEffectsFactoryHidlEnvironment* Instance() {
+        static AudioEffectsFactoryHidlEnvironment* instance =
+            new AudioEffectsFactoryHidlEnvironment;
+        return instance;
+    }
+
+    virtual void registerTestServices() override { registerTestService<IEffectsFactory>(); }
+};
+
+// The main test class for Audio Effects Factory HIDL HAL.
+class AudioEffectsFactoryHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+   public:
+    void SetUp() override {
+        effectsFactory = ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>(
+            AudioEffectsFactoryHidlEnvironment::Instance()->getServiceName<IEffectsFactory>());
+        ASSERT_NE(effectsFactory, nullptr);
+    }
+
+    void TearDown() override { effectsFactory.clear(); }
+
+   protected:
+    static void description(const std::string& description) {
+        RecordProperty("description", description);
+    }
+
+    sp<IEffectsFactory> effectsFactory;
+};
+
+TEST_F(AudioEffectsFactoryHidlTest, EnumerateEffects) {
+    description("Verify that EnumerateEffects returns at least one effect");
+    Result retval = Result::NOT_INITIALIZED;
+    size_t effectCount = 0;
+    Return<void> ret =
+        effectsFactory->getAllDescriptors([&](Result r, const hidl_vec<EffectDescriptor>& result) {
+            retval = r;
+            effectCount = result.size();
+        });
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, retval);
+    EXPECT_GT(effectCount, 0u);
+}
+
+TEST_F(AudioEffectsFactoryHidlTest, CreateEffect) {
+    description("Verify that an effect can be created via CreateEffect");
+    bool gotEffect = false;
+    Uuid effectUuid;
+    Return<void> ret =
+        effectsFactory->getAllDescriptors([&](Result r, const hidl_vec<EffectDescriptor>& result) {
+            if (r == Result::OK && result.size() > 0) {
+                gotEffect = true;
+                effectUuid = result[0].uuid;
+            }
+        });
+    ASSERT_TRUE(ret.isOk());
+    ASSERT_TRUE(gotEffect);
+    Result retval = Result::NOT_INITIALIZED;
+    sp<IEffect> effect;
+    ret = effectsFactory->createEffect(
+        effectUuid, 1 /*session*/, 1 /*ioHandle*/,
+        [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
+            retval = r;
+            if (r == Result::OK) {
+                effect = result;
+            }
+        });
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, retval);
+    EXPECT_NE(nullptr, effect.get());
+}
+
+TEST_F(AudioEffectsFactoryHidlTest, GetDescriptor) {
+    description(
+        "Verify that effects factory can provide an effect descriptor via "
+        "GetDescriptor");
+    hidl_vec<EffectDescriptor> allDescriptors;
+    Return<void> ret =
+        effectsFactory->getAllDescriptors([&](Result r, const hidl_vec<EffectDescriptor>& result) {
+            if (r == Result::OK) {
+                allDescriptors = result;
+            }
+        });
+    ASSERT_TRUE(ret.isOk());
+    ASSERT_GT(allDescriptors.size(), 0u);
+    for (size_t i = 0; i < allDescriptors.size(); ++i) {
+        ret = effectsFactory->getDescriptor(allDescriptors[i].uuid,
+                                            [&](Result r, const EffectDescriptor& result) {
+                                                EXPECT_EQ(r, Result::OK);
+                                                EXPECT_EQ(result, allDescriptors[i]);
+                                            });
+    }
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectsFactoryHidlTest, DebugDumpInvalidArgument) {
+    description("Verify that debugDump doesn't crash on invalid arguments");
+#if MAJOR_VERSION == 2
+    Return<void> ret = effectsFactory->debugDump(hidl_handle());
+#elif MAJOR_VERSION >= 4
+    Return<void> ret = effectsFactory->debug(hidl_handle(), {});
+#endif
+    ASSERT_TRUE(ret.isOk());
+}
+
+// Equalizer effect is required by CDD, but only the type is fixed.
+// This is the same UUID as AudioEffect.EFFECT_TYPE_EQUALIZER in Java.
+static const Uuid EQUALIZER_EFFECT_TYPE = {
+    0x0bed4300, 0xddd6, 0x11db, 0x8f34,
+    std::array<uint8_t, 6>{{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}};
+// Loudness Enhancer effect is required by CDD, but only the type is fixed.
+// This is the same UUID as AudioEffect.EFFECT_TYPE_LOUDNESS_ENHANCER in Java.
+static const Uuid LOUDNESS_ENHANCER_EFFECT_TYPE = {
+    0xfe3199be, 0xaed0, 0x413f, 0x87bb,
+    std::array<uint8_t, 6>{{0x11, 0x26, 0x0e, 0xb6, 0x3c, 0xf1}}};
+
+// The main test class for Audio Effect HIDL HAL.
+class AudioEffectHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+   public:
+    void SetUp() override {
+        effectsFactory = ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>();
+        ASSERT_NE(nullptr, effectsFactory.get());
+
+        findAndCreateEffect(getEffectType());
+        ASSERT_NE(nullptr, effect.get());
+
+        Return<Result> ret = effect->init();
+        ASSERT_TRUE(ret.isOk());
+        ASSERT_EQ(Result::OK, ret);
+    }
+
+    void TearDown() override {
+        effect.clear();
+        effectsFactory.clear();
+    }
+
+   protected:
+    static void description(const std::string& description) {
+        RecordProperty("description", description);
+    }
+
+    virtual Uuid getEffectType() { return EQUALIZER_EFFECT_TYPE; }
+
+    void findAndCreateEffect(const Uuid& type);
+    void findEffectInstance(const Uuid& type, Uuid* uuid);
+    void getChannelCount(uint32_t* channelCount);
+
+    sp<IEffectsFactory> effectsFactory;
+    sp<IEffect> effect;
+};
+
+void AudioEffectHidlTest::findAndCreateEffect(const Uuid& type) {
+    Uuid effectUuid;
+    findEffectInstance(type, &effectUuid);
+    Return<void> ret = effectsFactory->createEffect(
+        effectUuid, 1 /*session*/, 1 /*ioHandle*/,
+        [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
+            if (r == Result::OK) {
+                effect = result;
+            }
+        });
+    ASSERT_TRUE(ret.isOk());
+}
+
+void AudioEffectHidlTest::findEffectInstance(const Uuid& type, Uuid* uuid) {
+    bool effectFound = false;
+    Return<void> ret =
+        effectsFactory->getAllDescriptors([&](Result r, const hidl_vec<EffectDescriptor>& result) {
+            if (r == Result::OK) {
+                for (const auto& desc : result) {
+                    if (desc.type == type) {
+                        effectFound = true;
+                        *uuid = desc.uuid;
+                        break;
+                    }
+                }
+            }
+        });
+    ASSERT_TRUE(ret.isOk());
+    ASSERT_TRUE(effectFound);
+}
+
+void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) {
+    Result retval;
+    EffectConfig currentConfig;
+    Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
+        retval = r;
+        if (r == Result::OK) {
+            currentConfig = conf;
+        }
+    });
+    ASSERT_TRUE(ret.isOk());
+    ASSERT_EQ(Result::OK, retval);
+    ASSERT_TRUE(audio_channel_mask_is_valid(
+        static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels)));
+    *channelCount = audio_channel_count_from_out_mask(
+        static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels));
+}
+
+TEST_F(AudioEffectHidlTest, Close) {
+    description("Verify that an effect can be closed");
+    Return<Result> ret = effect->close();
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, ret);
+}
+
+TEST_F(AudioEffectHidlTest, GetDescriptor) {
+    description("Verify that an effect can return its own descriptor via GetDescriptor");
+    Result retval = Result::NOT_INITIALIZED;
+    Uuid actualType;
+    Return<void> ret = effect->getDescriptor([&](Result r, const EffectDescriptor& desc) {
+        retval = r;
+        if (r == Result::OK) {
+            actualType = desc.type;
+        }
+    });
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, retval);
+    EXPECT_EQ(getEffectType(), actualType);
+}
+
+TEST_F(AudioEffectHidlTest, GetSetConfig) {
+    description(
+        "Verify that it is possible to manipulate effect config via Get / "
+        "SetConfig");
+    Result retval = Result::NOT_INITIALIZED;
+    EffectConfig currentConfig;
+    Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
+        retval = r;
+        if (r == Result::OK) {
+            currentConfig = conf;
+        }
+    });
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, retval);
+    Return<Result> ret2 = effect->setConfig(currentConfig, nullptr, nullptr);
+    EXPECT_TRUE(ret2.isOk());
+    EXPECT_EQ(Result::OK, ret2);
+}
+
+TEST_F(AudioEffectHidlTest, GetConfigReverse) {
+    description("Verify that GetConfigReverse does not crash");
+    Return<void> ret = effect->getConfigReverse([&](Result, const EffectConfig&) {});
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectHidlTest, GetSupportedAuxChannelsConfigs) {
+    description("Verify that GetSupportedAuxChannelsConfigs does not crash");
+    Return<void> ret = effect->getSupportedAuxChannelsConfigs(
+        0, [&](Result, const hidl_vec<EffectAuxChannelsConfig>&) {});
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectHidlTest, GetAuxChannelsConfig) {
+    description("Verify that GetAuxChannelsConfig does not crash");
+    Return<void> ret = effect->getAuxChannelsConfig([&](Result, const EffectAuxChannelsConfig&) {});
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectHidlTest, SetAuxChannelsConfig) {
+    description("Verify that SetAuxChannelsConfig does not crash");
+    Return<Result> ret = effect->setAuxChannelsConfig(EffectAuxChannelsConfig());
+    EXPECT_TRUE(ret.isOk());
+}
+
+// Not generated automatically because AudioBuffer contains
+// instances of hidl_memory which can't be compared properly
+// in general case due to presence of handles.
+//
+// However, in this particular case, handles must not present
+// thus comparison is possible.
+//
+// operator== must be defined in the same namespace as the structures.
+namespace android {
+namespace hardware {
+namespace audio {
+namespace effect {
+namespace CPP_VERSION {
+inline bool operator==(const AudioBuffer& lhs, const AudioBuffer& rhs) {
+    return lhs.id == rhs.id && lhs.frameCount == rhs.frameCount && lhs.data.handle() == nullptr &&
+           rhs.data.handle() == nullptr;
+}
+
+inline bool operator==(const EffectBufferConfig& lhs, const EffectBufferConfig& rhs) {
+    return lhs.buffer == rhs.buffer && lhs.samplingRateHz == rhs.samplingRateHz &&
+           lhs.channels == rhs.channels && lhs.format == rhs.format &&
+           lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask;
+}
+
+inline bool operator==(const EffectConfig& lhs, const EffectConfig& rhs) {
+    return lhs.inputCfg == rhs.inputCfg && lhs.outputCfg == rhs.outputCfg;
+}
+}  // namespace CPP_VERSION
+}  // namespace effect
+}  // namespace audio
+}  // namespace hardware
+}  // namespace android
+
+TEST_F(AudioEffectHidlTest, Reset) {
+    description("Verify that Reset preserves effect configuration");
+    Result retval = Result::NOT_INITIALIZED;
+    EffectConfig originalConfig;
+    Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
+        retval = r;
+        if (r == Result::OK) {
+            originalConfig = conf;
+        }
+    });
+    ASSERT_TRUE(ret.isOk());
+    ASSERT_EQ(Result::OK, retval);
+    Return<Result> ret2 = effect->reset();
+    EXPECT_TRUE(ret2.isOk());
+    EXPECT_EQ(Result::OK, ret2);
+    EffectConfig configAfterReset;
+    ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
+        retval = r;
+        if (r == Result::OK) {
+            configAfterReset = conf;
+        }
+    });
+    EXPECT_EQ(originalConfig, configAfterReset);
+}
+
+TEST_F(AudioEffectHidlTest, DisableEnableDisable) {
+    description("Verify Disable -> Enable -> Disable sequence for an effect");
+    Return<Result> ret = effect->disable();
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::INVALID_ARGUMENTS, ret);
+    ret = effect->enable();
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, ret);
+    ret = effect->disable();
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, ret);
+}
+
+TEST_F(AudioEffectHidlTest, SetDevice) {
+    description("Verify that SetDevice works for an output chain effect");
+    Return<Result> ret = effect->setDevice(mkEnumBitfield(AudioDevice::OUT_SPEAKER));
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, ret);
+}
+
+TEST_F(AudioEffectHidlTest, SetAndGetVolume) {
+    description("Verify that SetAndGetVolume method works for an effect");
+    uint32_t channelCount;
+    getChannelCount(&channelCount);
+    hidl_vec<uint32_t> volumes;
+    volumes.resize(channelCount);
+    for (uint32_t i = 0; i < channelCount; ++i) {
+        volumes[i] = 0;
+    }
+    Result retval = Result::NOT_INITIALIZED;
+    Return<void> ret =
+        effect->setAndGetVolume(volumes, [&](Result r, const hidl_vec<uint32_t>&) { retval = r; });
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, retval);
+}
+
+TEST_F(AudioEffectHidlTest, VolumeChangeNotification) {
+    description("Verify that effect accepts VolumeChangeNotification");
+    uint32_t channelCount;
+    getChannelCount(&channelCount);
+    hidl_vec<uint32_t> volumes;
+    volumes.resize(channelCount);
+    for (uint32_t i = 0; i < channelCount; ++i) {
+        volumes[i] = 0;
+    }
+    Return<Result> ret = effect->volumeChangeNotification(volumes);
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, ret);
+}
+
+TEST_F(AudioEffectHidlTest, SetAudioMode) {
+    description("Verify that SetAudioMode works for an effect");
+    Return<Result> ret = effect->setAudioMode(AudioMode::NORMAL);
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, ret);
+}
+
+TEST_F(AudioEffectHidlTest, SetConfigReverse) {
+    description("Verify that SetConfigReverse does not crash");
+    Return<Result> ret = effect->setConfigReverse(EffectConfig(), nullptr, nullptr);
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectHidlTest, SetInputDevice) {
+    description("Verify that SetInputDevice does not crash");
+    Return<Result> ret = effect->setInputDevice(mkEnumBitfield(AudioDevice::IN_BUILTIN_MIC));
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectHidlTest, SetAudioSource) {
+    description("Verify that SetAudioSource does not crash");
+    Return<Result> ret = effect->setAudioSource(AudioSource::MIC);
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectHidlTest, Offload) {
+    description("Verify that calling Offload method does not crash");
+    EffectOffloadParameter offloadParam;
+    offloadParam.isOffload = false;
+    offloadParam.ioHandle = static_cast<int>(AudioHandleConsts::AUDIO_IO_HANDLE_NONE);
+    Return<Result> ret = effect->offload(offloadParam);
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectHidlTest, PrepareForProcessing) {
+    description("Verify that PrepareForProcessing method works for an effect");
+    Result retval = Result::NOT_INITIALIZED;
+    Return<void> ret = effect->prepareForProcessing(
+        [&](Result r, const MQDescriptorSync<Result>&) { retval = r; });
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, retval);
+}
+
+TEST_F(AudioEffectHidlTest, SetProcessBuffers) {
+    description("Verify that SetProcessBuffers works for an effect");
+    sp<IAllocator> ashmem = IAllocator::getService("ashmem");
+    ASSERT_NE(nullptr, ashmem.get());
+    bool success = false;
+    AudioBuffer buffer;
+    Return<void> ret = ashmem->allocate(1024, [&](bool s, const hidl_memory& memory) {
+        success = s;
+        if (s) {
+            buffer.data = memory;
+        }
+    });
+    ASSERT_TRUE(ret.isOk());
+    ASSERT_TRUE(success);
+    Return<Result> ret2 = effect->setProcessBuffers(buffer, buffer);
+    EXPECT_TRUE(ret2.isOk());
+    EXPECT_EQ(Result::OK, ret2);
+}
+
+TEST_F(AudioEffectHidlTest, Command) {
+    description("Verify that Command does not crash");
+    Return<void> ret =
+        effect->command(0, hidl_vec<uint8_t>(), 0, [&](int32_t, const hidl_vec<uint8_t>&) {});
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectHidlTest, SetParameter) {
+    description("Verify that SetParameter does not crash");
+    Return<Result> ret = effect->setParameter(hidl_vec<uint8_t>(), hidl_vec<uint8_t>());
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectHidlTest, GetParameter) {
+    description("Verify that GetParameter does not crash");
+    Return<void> ret =
+        effect->getParameter(hidl_vec<uint8_t>(), 0, [&](Result, const hidl_vec<uint8_t>&) {});
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectHidlTest, GetSupportedConfigsForFeature) {
+    description("Verify that GetSupportedConfigsForFeature does not crash");
+    Return<void> ret = effect->getSupportedConfigsForFeature(
+        0, 0, 0, [&](Result, uint32_t, const hidl_vec<uint8_t>&) {});
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectHidlTest, GetCurrentConfigForFeature) {
+    description("Verify that GetCurrentConfigForFeature does not crash");
+    Return<void> ret =
+        effect->getCurrentConfigForFeature(0, 0, [&](Result, const hidl_vec<uint8_t>&) {});
+    EXPECT_TRUE(ret.isOk());
+}
+
+TEST_F(AudioEffectHidlTest, SetCurrentConfigForFeature) {
+    description("Verify that SetCurrentConfigForFeature does not crash");
+    Return<Result> ret = effect->setCurrentConfigForFeature(0, hidl_vec<uint8_t>());
+    EXPECT_TRUE(ret.isOk());
+}
+
+// The main test class for Equalizer Audio Effect HIDL HAL.
+class EqualizerAudioEffectHidlTest : public AudioEffectHidlTest {
+   public:
+    void SetUp() override {
+        AudioEffectHidlTest::SetUp();
+        equalizer = IEqualizerEffect::castFrom(effect);
+        ASSERT_NE(nullptr, equalizer.get());
+    }
+
+   protected:
+    Uuid getEffectType() override { return EQUALIZER_EFFECT_TYPE; }
+    void getNumBands(uint16_t* numBands);
+    void getLevelRange(int16_t* minLevel, int16_t* maxLevel);
+    void getBandFrequencyRange(uint16_t band, uint32_t* minFreq, uint32_t* centerFreq,
+                               uint32_t* maxFreq);
+    void getPresetCount(size_t* count);
+
+    sp<IEqualizerEffect> equalizer;
+};
+
+void EqualizerAudioEffectHidlTest::getNumBands(uint16_t* numBands) {
+    Result retval = Result::NOT_INITIALIZED;
+    Return<void> ret = equalizer->getNumBands([&](Result r, uint16_t b) {
+        retval = r;
+        if (retval == Result::OK) {
+            *numBands = b;
+        }
+    });
+    ASSERT_TRUE(ret.isOk());
+    ASSERT_EQ(Result::OK, retval);
+}
+
+void EqualizerAudioEffectHidlTest::getLevelRange(int16_t* minLevel, int16_t* maxLevel) {
+    Result retval = Result::NOT_INITIALIZED;
+    Return<void> ret = equalizer->getLevelRange([&](Result r, int16_t min, int16_t max) {
+        retval = r;
+        if (retval == Result::OK) {
+            *minLevel = min;
+            *maxLevel = max;
+        }
+    });
+    ASSERT_TRUE(ret.isOk());
+    ASSERT_EQ(Result::OK, retval);
+}
+
+void EqualizerAudioEffectHidlTest::getBandFrequencyRange(uint16_t band, uint32_t* minFreq,
+                                                         uint32_t* centerFreq, uint32_t* maxFreq) {
+    Result retval = Result::NOT_INITIALIZED;
+    Return<void> ret =
+        equalizer->getBandFrequencyRange(band, [&](Result r, uint32_t min, uint32_t max) {
+            retval = r;
+            if (retval == Result::OK) {
+                *minFreq = min;
+                *maxFreq = max;
+            }
+        });
+    ASSERT_TRUE(ret.isOk());
+    ASSERT_EQ(Result::OK, retval);
+    ret = equalizer->getBandCenterFrequency(band, [&](Result r, uint32_t center) {
+        retval = r;
+        if (retval == Result::OK) {
+            *centerFreq = center;
+        }
+    });
+    ASSERT_TRUE(ret.isOk());
+    ASSERT_EQ(Result::OK, retval);
+}
+
+void EqualizerAudioEffectHidlTest::getPresetCount(size_t* count) {
+    Result retval = Result::NOT_INITIALIZED;
+    Return<void> ret = equalizer->getPresetNames([&](Result r, const hidl_vec<hidl_string>& names) {
+        retval = r;
+        if (retval == Result::OK) {
+            *count = names.size();
+        }
+    });
+    ASSERT_TRUE(ret.isOk());
+    ASSERT_EQ(Result::OK, retval);
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetNumBands) {
+    description("Verify that Equalizer effect reports at least one band");
+    uint16_t numBands = 0;
+    getNumBands(&numBands);
+    EXPECT_GT(numBands, 0);
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetLevelRange) {
+    description("Verify that Equalizer effect reports adequate band level range");
+    int16_t minLevel = 0x7fff, maxLevel = 0;
+    getLevelRange(&minLevel, &maxLevel);
+    EXPECT_GT(maxLevel, minLevel);
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetSetBandLevel) {
+    description("Verify that manipulating band levels works for Equalizer effect");
+    uint16_t numBands = 0;
+    getNumBands(&numBands);
+    ASSERT_GT(numBands, 0);
+    int16_t levels[3]{0x7fff, 0, 0};
+    getLevelRange(&levels[0], &levels[2]);
+    ASSERT_GT(levels[2], levels[0]);
+    levels[1] = (levels[2] + levels[0]) / 2;
+    for (uint16_t i = 0; i < numBands; ++i) {
+        for (size_t j = 0; j < ARRAY_SIZE(levels); ++j) {
+            Return<Result> ret = equalizer->setBandLevel(i, levels[j]);
+            EXPECT_TRUE(ret.isOk());
+            EXPECT_EQ(Result::OK, ret);
+            Result retval = Result::NOT_INITIALIZED;
+            int16_t actualLevel;
+            Return<void> ret2 = equalizer->getBandLevel(i, [&](Result r, int16_t l) {
+                retval = r;
+                if (retval == Result::OK) {
+                    actualLevel = l;
+                }
+            });
+            EXPECT_TRUE(ret2.isOk());
+            EXPECT_EQ(Result::OK, retval);
+            EXPECT_EQ(levels[j], actualLevel);
+        }
+    }
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetBandCenterFrequencyAndRange) {
+    description("Verify that Equalizer effect reports adequate band frequency range");
+    uint16_t numBands = 0;
+    getNumBands(&numBands);
+    ASSERT_GT(numBands, 0);
+    for (uint16_t i = 0; i < numBands; ++i) {
+        uint32_t minFreq = 0xffffffff, centerFreq = 0xffffffff, maxFreq = 0xffffffff;
+        getBandFrequencyRange(i, &minFreq, &centerFreq, &maxFreq);
+        // Note: NXP legacy implementation reports "1" as upper bound for last band,
+        // so this check fails.
+        EXPECT_GE(maxFreq, centerFreq);
+        EXPECT_GE(centerFreq, minFreq);
+    }
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetBandForFrequency) {
+    description("Verify that Equalizer effect supports GetBandForFrequency correctly");
+    uint16_t numBands = 0;
+    getNumBands(&numBands);
+    ASSERT_GT(numBands, 0);
+    for (uint16_t i = 0; i < numBands; ++i) {
+        uint32_t freqs[3]{0, 0, 0};
+        getBandFrequencyRange(i, &freqs[0], &freqs[1], &freqs[2]);
+        // NXP legacy implementation reports "1" as upper bound for last band, some
+        // of the checks fail.
+        for (size_t j = 0; j < ARRAY_SIZE(freqs); ++j) {
+            if (j == 0) {
+                freqs[j]++;
+            }  // Min frequency is an open interval.
+            Result retval = Result::NOT_INITIALIZED;
+            uint16_t actualBand = numBands + 1;
+            Return<void> ret = equalizer->getBandForFrequency(freqs[j], [&](Result r, uint16_t b) {
+                retval = r;
+                if (retval == Result::OK) {
+                    actualBand = b;
+                }
+            });
+            EXPECT_TRUE(ret.isOk());
+            EXPECT_EQ(Result::OK, retval);
+            EXPECT_EQ(i, actualBand) << "Frequency: " << freqs[j];
+        }
+    }
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetPresetNames) {
+    description("Verify that Equalizer effect reports at least one preset");
+    size_t presetCount;
+    getPresetCount(&presetCount);
+    EXPECT_GT(presetCount, 0u);
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetSetCurrentPreset) {
+    description("Verify that manipulating the current preset for Equalizer effect");
+    size_t presetCount;
+    getPresetCount(&presetCount);
+    ASSERT_GT(presetCount, 0u);
+    for (uint16_t i = 0; i < presetCount; ++i) {
+        Return<Result> ret = equalizer->setCurrentPreset(i);
+        EXPECT_TRUE(ret.isOk());
+        EXPECT_EQ(Result::OK, ret);
+        Result retval = Result::NOT_INITIALIZED;
+        uint16_t actualPreset = 0xffff;
+        Return<void> ret2 = equalizer->getCurrentPreset([&](Result r, uint16_t p) {
+            retval = r;
+            if (retval == Result::OK) {
+                actualPreset = p;
+            }
+        });
+        EXPECT_TRUE(ret2.isOk());
+        EXPECT_EQ(Result::OK, retval);
+        EXPECT_EQ(i, actualPreset);
+    }
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetSetAllProperties) {
+    description(
+        "Verify that setting band levels and presets works via Get / "
+        "SetAllProperties for Equalizer effect");
+    using AllProperties =
+        android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect::AllProperties;
+    uint16_t numBands = 0;
+    getNumBands(&numBands);
+    ASSERT_GT(numBands, 0);
+    AllProperties props;
+    props.bandLevels.resize(numBands);
+    for (size_t i = 0; i < numBands; ++i) {
+        props.bandLevels[i] = 0;
+    }
+
+    AllProperties actualProps;
+    Result retval = Result::NOT_INITIALIZED;
+
+    // Verify setting of the band levels via properties.
+    props.curPreset = -1;
+    Return<Result> ret = equalizer->setAllProperties(props);
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, ret);
+    Return<void> ret2 = equalizer->getAllProperties([&](Result r, AllProperties p) {
+        retval = r;
+        if (retval == Result::OK) {
+            actualProps = p;
+        }
+    });
+    EXPECT_TRUE(ret2.isOk());
+    EXPECT_EQ(Result::OK, retval);
+    EXPECT_EQ(props.bandLevels, actualProps.bandLevels);
+
+    // Verify setting of the current preset via properties.
+    props.curPreset = 0;  // Assuming there is at least one preset.
+    ret = equalizer->setAllProperties(props);
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, ret);
+    ret2 = equalizer->getAllProperties([&](Result r, AllProperties p) {
+        retval = r;
+        if (retval == Result::OK) {
+            actualProps = p;
+        }
+    });
+    EXPECT_TRUE(ret2.isOk());
+    EXPECT_EQ(Result::OK, retval);
+    EXPECT_EQ(props.curPreset, actualProps.curPreset);
+}
+
+// The main test class for Equalizer Audio Effect HIDL HAL.
+class LoudnessEnhancerAudioEffectHidlTest : public AudioEffectHidlTest {
+   public:
+    void SetUp() override {
+        AudioEffectHidlTest::SetUp();
+        enhancer = ILoudnessEnhancerEffect::castFrom(effect);
+        ASSERT_NE(nullptr, enhancer.get());
+    }
+
+   protected:
+    Uuid getEffectType() override { return LOUDNESS_ENHANCER_EFFECT_TYPE; }
+
+    sp<ILoudnessEnhancerEffect> enhancer;
+};
+
+TEST_F(LoudnessEnhancerAudioEffectHidlTest, GetSetTargetGain) {
+    description(
+        "Verify that manipulating the target gain works for Loudness Enhancer "
+        "effect");
+    const int32_t gain = 100;
+    Return<Result> ret = enhancer->setTargetGain(gain);
+    EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, ret);
+    int32_t actualGain = 0;
+    Result retval;
+    Return<void> ret2 = enhancer->getTargetGain([&](Result r, int32_t g) {
+        retval = r;
+        if (retval == Result::OK) {
+            actualGain = g;
+        }
+    });
+    EXPECT_TRUE(ret2.isOk());
+    EXPECT_EQ(Result::OK, retval);
+    EXPECT_EQ(gain, actualGain);
+}
+
+int main(int argc, char** argv) {
+    ::testing::AddGlobalTestEnvironment(AudioEffectsFactoryHidlEnvironment::Instance());
+    ::testing::InitGoogleTest(&argc, argv);
+    AudioEffectsFactoryHidlEnvironment::Instance()->init(&argc, argv);
+    int status = RUN_ALL_TESTS();
+    LOG(INFO) << "Test result = " << status;
+    return status;
+}
diff --git a/authsecret/1.0/vts/functional/Android.bp b/authsecret/1.0/vts/functional/Android.bp
index de9f560..f2b3a8a 100644
--- a/authsecret/1.0/vts/functional/Android.bp
+++ b/authsecret/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalAuthSecretV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.authsecret@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/automotive/audiocontrol/1.0/vts/functional/Android.bp b/automotive/audiocontrol/1.0/vts/functional/Android.bp
index c6e0d8e..3cb6340 100644
--- a/automotive/audiocontrol/1.0/vts/functional/Android.bp
+++ b/automotive/audiocontrol/1.0/vts/functional/Android.bp
@@ -16,16 +16,14 @@
 
 cc_test {
     name: "VtsHalAudioControlV1_0TargetTest",
-
     srcs: [
         "VtsHalAudioControlV1_0TargetTest.cpp",
     ],
-
     defaults: [
         "VtsHalTargetTestDefaults",
     ],
-
     static_libs: [
         "android.hardware.automotive.audiocontrol@1.0",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/automotive/evs/1.0/vts/functional/Android.bp b/automotive/evs/1.0/vts/functional/Android.bp
index 5d696fc..2ef33fd 100644
--- a/automotive/evs/1.0/vts/functional/Android.bp
+++ b/automotive/evs/1.0/vts/functional/Android.bp
@@ -16,21 +16,17 @@
 
 cc_test {
     name: "VtsHalEvsV1_0TargetTest",
-
     srcs: [
         "VtsHalEvsV1_0TargetTest.cpp",
         "FrameHandler.cpp",
         "FormatConvert.cpp"
     ],
-
     defaults: ["VtsHalTargetTestDefaults"],
-
     shared_libs: [
         "libui",
     ],
-
     static_libs: ["android.hardware.automotive.evs@1.0"],
-
+    test_suites: ["general-tests"],
     cflags: [
         "-O0",
         "-g",
diff --git a/automotive/vehicle/2.0/default/Android.bp b/automotive/vehicle/2.0/default/Android.bp
index 7802ef0..a11d452 100644
--- a/automotive/vehicle/2.0/default/Android.bp
+++ b/automotive/vehicle/2.0/default/Android.bp
@@ -95,6 +95,7 @@
         "tests/VmsUtils_test.cpp",
     ],
     header_libs: ["libbase_headers"],
+    test_suites: ["general-tests"],
 }
 
 cc_binary {
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
index 5007a6d..7909ac1 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
@@ -381,8 +381,8 @@
                 // kHvacPowerProperties.
                 .configArray =
                     {
-                        0x12400500,  // HVAC_FAN_SPEED
-                        0x12400501   // HVAC_FAN_DIRECTION
+                        toInt(VehicleProperty::HVAC_FAN_SPEED),
+                        toInt(VehicleProperty::HVAC_FAN_DIRECTION)
                     }},
      .initialValue = {.int32Values = {1}}},
 
diff --git a/biometrics/fingerprint/2.1/default/android.hardware.biometrics.fingerprint@2.1-service.rc b/biometrics/fingerprint/2.1/default/android.hardware.biometrics.fingerprint@2.1-service.rc
index 9bfd3ba..1667677 100644
--- a/biometrics/fingerprint/2.1/default/android.hardware.biometrics.fingerprint@2.1-service.rc
+++ b/biometrics/fingerprint/2.1/default/android.hardware.biometrics.fingerprint@2.1-service.rc
@@ -4,5 +4,5 @@
     # /data is mounted.
     class late_start
     user system
-    group system input
-    writepid /dev/cpuset/system-background/tasks
\ No newline at end of file
+    group system input uhid
+    writepid /dev/cpuset/system-background/tasks
diff --git a/biometrics/fingerprint/2.1/vts/functional/Android.bp b/biometrics/fingerprint/2.1/vts/functional/Android.bp
index bee3657..60228f2 100644
--- a/biometrics/fingerprint/2.1/vts/functional/Android.bp
+++ b/biometrics/fingerprint/2.1/vts/functional/Android.bp
@@ -19,5 +19,6 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalBiometricsFingerprintV2_1TargetTest.cpp"],
     static_libs: ["android.hardware.biometrics.fingerprint@2.1"],
+    test_suites: ["general-tests"],
 }
 
diff --git a/bluetooth/1.0/default/Android.bp b/bluetooth/1.0/default/Android.bp
index 48bbadf..f4b1e7b 100644
--- a/bluetooth/1.0/default/Android.bp
+++ b/bluetooth/1.0/default/Android.bp
@@ -94,6 +94,7 @@
         "android.hardware.bluetooth-hci",
         "libgmock",
     ],
+    test_suites: ["general-tests"],
 }
 
 cc_test_host {
diff --git a/bluetooth/1.0/default/android.hardware.bluetooth@1.0-service.rc b/bluetooth/1.0/default/android.hardware.bluetooth@1.0-service.rc
index a634441..b615227 100644
--- a/bluetooth/1.0/default/android.hardware.bluetooth@1.0-service.rc
+++ b/bluetooth/1.0/default/android.hardware.bluetooth@1.0-service.rc
@@ -5,11 +5,3 @@
     group bluetooth
     writepid /dev/stune/foreground/tasks
 
-on property:vts.native_server.on=1 && property:ro.build.type=userdebug
-    stop vendor.bluetooth-1-0
-on property:vts.native_server.on=1 && property:ro.build.type=eng
-    stop vendor.bluetooth-1-0
-on property:vts.native_server.on=0 && property:ro.build.type=userdebug
-    start vendor.bluetooth-1-0
-on property:vts.native_server.on=0 && property:ro.build.type=eng
-    start vendor.bluetooth-1-0
diff --git a/bluetooth/1.0/default/vendor_interface.cc b/bluetooth/1.0/default/vendor_interface.cc
index e5f02f3..d56e344 100644
--- a/bluetooth/1.0/default/vendor_interface.cc
+++ b/bluetooth/1.0/default/vendor_interface.cc
@@ -294,6 +294,7 @@
     lib_interface_->op(BT_VND_OP_POWER_CTRL, &power_state);
 
     lib_interface_->cleanup();
+    lib_interface_ = nullptr;
   }
 
   if (lib_handle_ != nullptr) {
diff --git a/bluetooth/1.0/default/vendor_interface.h b/bluetooth/1.0/default/vendor_interface.h
index 36f4e1b..1d69040 100644
--- a/bluetooth/1.0/default/vendor_interface.h
+++ b/bluetooth/1.0/default/vendor_interface.h
@@ -58,15 +58,15 @@
 
   void HandleIncomingEvent(const hidl_vec<uint8_t>& hci_packet);
 
-  void* lib_handle_;
-  bt_vendor_interface_t* lib_interface_;
+  void* lib_handle_ = nullptr;
+  bt_vendor_interface_t* lib_interface_ = nullptr;
   async::AsyncFdWatcher fd_watcher_;
   InitializeCompleteCallback initialize_complete_cb_;
-  hci::HciProtocol* hci_;
+  hci::HciProtocol* hci_ = nullptr;
 
   PacketReadCallback event_cb_;
 
-  FirmwareStartupTimer* firmware_startup_timer_;
+  FirmwareStartupTimer* firmware_startup_timer_ = nullptr;
 };
 
 }  // namespace implementation
diff --git a/bluetooth/1.0/vts/OWNERS b/bluetooth/1.0/vts/OWNERS
new file mode 100644
index 0000000..58d3a66
--- /dev/null
+++ b/bluetooth/1.0/vts/OWNERS
@@ -0,0 +1,8 @@
+zachoverflow@google.com
+siyuanh@google.com
+mylesgw@google.com
+jpawlowski@google.com
+apanicke@google.com
+stng@google.com
+hsz@google.com
+
diff --git a/bluetooth/1.0/vts/functional/Android.bp b/bluetooth/1.0/vts/functional/Android.bp
index 2e60588..54039e5 100644
--- a/bluetooth/1.0/vts/functional/Android.bp
+++ b/bluetooth/1.0/vts/functional/Android.bp
@@ -22,4 +22,5 @@
         "android.hardware.bluetooth@1.0",
         "libbluetooth-types",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
index 88d4234..beb9a3e 100644
--- a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
+++ b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
@@ -26,7 +26,10 @@
 #include <VtsHalHidlTargetCallbackBase.h>
 #include <VtsHalHidlTargetTestBase.h>
 #include <VtsHalHidlTargetTestEnvBase.h>
+
+#include <chrono>
 #include <queue>
+#include <thread>
 
 using ::android::sp;
 using ::android::hardware::hidl_death_recipient;
@@ -46,6 +49,7 @@
 #define WAIT_FOR_HCI_EVENT_TIMEOUT std::chrono::milliseconds(2000)
 #define WAIT_FOR_SCO_DATA_TIMEOUT std::chrono::milliseconds(1000)
 #define WAIT_FOR_ACL_DATA_TIMEOUT std::chrono::milliseconds(1000)
+#define INTERFACE_CLOSE_DELAY_MS std::chrono::milliseconds(200)
 
 #define COMMAND_HCI_SHOULD_BE_UNKNOWN \
   { 0xff, 0x3B, 0x08, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }
@@ -101,6 +105,9 @@
   (ACL_PACKET_BOUNDARY_FLAG_FIRST_AUTO_FLUSHABLE \
    << ACL_PACKET_BOUNDARY_FLAG_OFFSET)
 
+// To be removed in VTS release builds
+#define ACL_HANDLE_QCA_DEBUG_MESSAGE 0xedc
+
 constexpr char kCallbackNameAclEventReceived[] = "aclDataReceived";
 constexpr char kCallbackNameHciEventReceived[] = "hciEventReceived";
 constexpr char kCallbackNameInitializationComplete[] = "initializationComplete";
@@ -197,8 +204,10 @@
   }
 
   virtual void TearDown() override {
+    ALOGI("TearDown");
     // Should not be checked in production code
     ASSERT_TRUE(bluetooth->close().isOk());
+    std::this_thread::sleep_for(INTERFACE_CLOSE_DELAY_MS);
     handle_no_ops();
     EXPECT_EQ(static_cast<size_t>(0), event_queue.size());
     EXPECT_EQ(static_cast<size_t>(0), sco_queue.size());
@@ -222,9 +231,10 @@
 
   class BluetoothHciDeathRecipient : public hidl_death_recipient {
    public:
-    virtual void serviceDied(
+    void serviceDied(
         uint64_t /*cookie*/,
-        const android::wp<::android::hidl::base::V1_0::IBase>& /*who*/) {
+        const android::wp<::android::hidl::base::V1_0::IBase>& /*who*/)
+        override {
       FAIL();
     }
   };
@@ -308,7 +318,20 @@
     if (event_is_no_op) {
       event_queue.pop();
     } else {
-      return;
+      break;
+    }
+  }
+  // To be removed in VTS release builds
+  while (acl_queue.size() > 0) {
+    hidl_vec<uint8_t> acl_packet = acl_queue.front();
+    uint16_t connection_handle = acl_packet[1] & 0xF;
+    connection_handle <<= 8;
+    connection_handle |= acl_packet[0];
+    bool packet_is_no_op = connection_handle == ACL_HANDLE_QCA_DEBUG_MESSAGE;
+    if (packet_is_no_op) {
+      acl_queue.pop();
+    } else {
+      break;
     }
   }
 }
diff --git a/bluetooth/a2dp/1.0/vts/OWNERS b/bluetooth/a2dp/1.0/vts/OWNERS
new file mode 100644
index 0000000..58d3a66
--- /dev/null
+++ b/bluetooth/a2dp/1.0/vts/OWNERS
@@ -0,0 +1,8 @@
+zachoverflow@google.com
+siyuanh@google.com
+mylesgw@google.com
+jpawlowski@google.com
+apanicke@google.com
+stng@google.com
+hsz@google.com
+
diff --git a/bluetooth/a2dp/1.0/vts/functional/Android.bp b/bluetooth/a2dp/1.0/vts/functional/Android.bp
index f1ffc45..e50e167 100644
--- a/bluetooth/a2dp/1.0/vts/functional/Android.bp
+++ b/bluetooth/a2dp/1.0/vts/functional/Android.bp
@@ -23,4 +23,5 @@
         "android.hardware.bluetooth.a2dp@1.0",
         "libbluetooth-types",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/boot/1.0/vts/functional/Android.bp b/boot/1.0/vts/functional/Android.bp
index 2ef89f3..5d1a9cb 100644
--- a/boot/1.0/vts/functional/Android.bp
+++ b/boot/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalBootV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.boot@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/broadcastradio/1.0/vts/functional/Android.bp b/broadcastradio/1.0/vts/functional/Android.bp
index 7040a01..9ba9fbe 100644
--- a/broadcastradio/1.0/vts/functional/Android.bp
+++ b/broadcastradio/1.0/vts/functional/Android.bp
@@ -22,4 +22,5 @@
         "android.hardware.broadcastradio@1.0",
         "android.hardware.broadcastradio@vts-utils-lib",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/broadcastradio/1.1/vts/functional/Android.bp b/broadcastradio/1.1/vts/functional/Android.bp
index 9240cf0..0a02a69 100644
--- a/broadcastradio/1.1/vts/functional/Android.bp
+++ b/broadcastradio/1.1/vts/functional/Android.bp
@@ -25,4 +25,5 @@
         "android.hardware.broadcastradio@vts-utils-lib",
         "libgmock",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/broadcastradio/2.0/default/Android.bp b/broadcastradio/2.0/default/Android.bp
index 900454e..840c4b8 100644
--- a/broadcastradio/2.0/default/Android.bp
+++ b/broadcastradio/2.0/default/Android.bp
@@ -43,7 +43,6 @@
         "libbase",
         "libhidlbase",
         "libhidltransport",
-        "liblog",
         "libutils",
     ],
 }
diff --git a/broadcastradio/2.0/default/BroadcastRadio.cpp b/broadcastradio/2.0/default/BroadcastRadio.cpp
index 0148fec..28a0dd5 100644
--- a/broadcastradio/2.0/default/BroadcastRadio.cpp
+++ b/broadcastradio/2.0/default/BroadcastRadio.cpp
@@ -13,15 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#define LOG_TAG "BcRadioDef.module"
-#define LOG_NDEBUG 0
-
 #include "BroadcastRadio.h"
 
-#include <log/log.h>
-
 #include "resources.h"
 
+#include <android-base/logging.h>
+
 namespace android {
 namespace hardware {
 namespace broadcastradio {
@@ -66,7 +63,6 @@
       mAmFmConfig(gDefaultAmFmConfig) {}
 
 Return<void> BroadcastRadio::getProperties(getProperties_cb _hidl_cb) {
-    ALOGV("%s", __func__);
     _hidl_cb(mProperties);
     return {};
 }
@@ -77,8 +73,6 @@
 }
 
 Return<void> BroadcastRadio::getAmFmRegionConfig(bool full, getAmFmRegionConfig_cb _hidl_cb) {
-    ALOGV("%s(%d)", __func__, full);
-
     if (full) {
         AmFmRegionConfig config = {};
         config.ranges = hidl_vec<AmFmBandRange>({
@@ -96,8 +90,6 @@
 }
 
 Return<void> BroadcastRadio::getDabRegionConfig(getDabRegionConfig_cb _hidl_cb) {
-    ALOGV("%s", __func__);
-
     hidl_vec<DabTableEntry> config = {
         {"5A", 174928},  {"7D", 194064},  {"8A", 195936},  {"8B", 197648},  {"9A", 202928},
         {"9B", 204640},  {"9C", 206352},  {"10B", 211648}, {"10C", 213360}, {"10D", 215072},
@@ -111,7 +103,7 @@
 
 Return<void> BroadcastRadio::openSession(const sp<ITunerCallback>& callback,
                                          openSession_cb _hidl_cb) {
-    ALOGV("%s", __func__);
+    LOG(DEBUG) << "opening new session...";
 
     /* For the needs of default implementation it's fine to instantiate new session object
      * out of the lock scope. If your implementation needs it, use reentrant lock.
@@ -122,7 +114,7 @@
 
     auto oldSession = mSession.promote();
     if (oldSession != nullptr) {
-        ALOGI("Closing previously opened tuner");
+        LOG(INFO) << "closing previously opened tuner";
         oldSession->close();
         mSession = nullptr;
     }
@@ -134,14 +126,14 @@
 }
 
 Return<void> BroadcastRadio::getImage(uint32_t id, getImage_cb _hidl_cb) {
-    ALOGV("%s(%x)", __func__, id);
+    LOG(DEBUG) << "fetching image " << std::hex << id;
 
     if (id == resources::demoPngId) {
         _hidl_cb(std::vector<uint8_t>(resources::demoPng, std::end(resources::demoPng)));
         return {};
     }
 
-    ALOGI("Image %x doesn't exists", id);
+    LOG(INFO) << "image " << std::hex << id << " doesn't exists";
     _hidl_cb({});
     return {};
 }
@@ -149,7 +141,7 @@
 Return<void> BroadcastRadio::registerAnnouncementListener(
     const hidl_vec<AnnouncementType>& enabled, const sp<IAnnouncementListener>& /* listener */,
     registerAnnouncementListener_cb _hidl_cb) {
-    ALOGV("%s(%s)", __func__, toString(enabled).c_str());
+    LOG(DEBUG) << "registering announcement listener for " << toString(enabled);
 
     _hidl_cb(Result::NOT_SUPPORTED, nullptr);
     return {};
diff --git a/broadcastradio/2.0/default/TunerSession.cpp b/broadcastradio/2.0/default/TunerSession.cpp
index da97562..2ba4d02 100644
--- a/broadcastradio/2.0/default/TunerSession.cpp
+++ b/broadcastradio/2.0/default/TunerSession.cpp
@@ -14,15 +14,12 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "BcRadioDef.tuner"
-#define LOG_NDEBUG 0
-
 #include "TunerSession.h"
 
 #include "BroadcastRadio.h"
 
+#include <android-base/logging.h>
 #include <broadcastradio-utils-2x/Utils.h>
-#include <log/log.h>
 
 namespace android {
 namespace hardware {
@@ -68,7 +65,7 @@
 }
 
 void TunerSession::tuneInternalLocked(const ProgramSelector& sel) {
-    ALOGV("%s(%s)", __func__, toString(sel).c_str());
+    LOG(VERBOSE) << "tune (internal) to " << toString(sel);
 
     VirtualProgram virtualProgram;
     ProgramInfo programInfo;
@@ -93,17 +90,18 @@
 }
 
 Return<Result> TunerSession::tune(const ProgramSelector& sel) {
-    ALOGV("%s(%s)", __func__, toString(sel).c_str());
+    LOG(DEBUG) << "tune to " << toString(sel);
+
     lock_guard<mutex> lk(mMut);
     if (mIsClosed) return Result::INVALID_STATE;
 
     if (!utils::isSupported(module().mProperties, sel)) {
-        ALOGW("Selector not supported");
+        LOG(WARNING) << "selector not supported: " << toString(sel);
         return Result::NOT_SUPPORTED;
     }
 
     if (!utils::isValid(sel)) {
-        ALOGE("ProgramSelector is not valid");
+        LOG(ERROR) << "selector is not valid: " << toString(sel);
         return Result::INVALID_ARGUMENTS;
     }
 
@@ -119,8 +117,9 @@
     return Result::OK;
 }
 
-Return<Result> TunerSession::scan(bool directionUp, bool /* skipSubChannel */) {
-    ALOGV("%s", __func__);
+Return<Result> TunerSession::scan(bool directionUp, bool skipSubChannel) {
+    LOG(DEBUG) << "seek up=" << directionUp << " skipSubChannel=" << skipSubChannel;
+
     lock_guard<mutex> lk(mMut);
     if (mIsClosed) return Result::INVALID_STATE;
 
@@ -130,8 +129,8 @@
 
     if (list.empty()) {
         mIsTuneCompleted = false;
-        auto task = [this, directionUp]() {
-            ALOGI("Performing failed seek up=%d", directionUp);
+        auto task = [this]() {
+            LOG(DEBUG) << "program list is empty, seek couldn't stop";
 
             mCallback->onTuneFailed(Result::TIMEOUT, {});
         };
@@ -162,7 +161,7 @@
 
     mIsTuneCompleted = false;
     auto task = [this, tuneTo, directionUp]() {
-        ALOGI("Performing seek up=%d", directionUp);
+        LOG(VERBOSE) << "executing seek up=" << directionUp;
 
         lock_guard<mutex> lk(mMut);
         tuneInternalLocked(tuneTo);
@@ -173,21 +172,21 @@
 }
 
 Return<Result> TunerSession::step(bool directionUp) {
-    ALOGV("%s", __func__);
+    LOG(DEBUG) << "step up=" << directionUp;
     lock_guard<mutex> lk(mMut);
     if (mIsClosed) return Result::INVALID_STATE;
 
     cancelLocked();
 
     if (!utils::hasId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY)) {
-        ALOGE("Can't step in anything else than AM/FM");
+        LOG(WARNING) << "can't step in anything else than AM/FM";
         return Result::NOT_SUPPORTED;
     }
 
     auto stepTo = utils::getId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY);
     auto range = getAmFmRangeLocked();
     if (!range) {
-        ALOGE("Can't find current band");
+        LOG(ERROR) << "can't find current band";
         return Result::INTERNAL_ERROR;
     }
 
@@ -201,7 +200,7 @@
 
     mIsTuneCompleted = false;
     auto task = [this, stepTo]() {
-        ALOGI("Performing step to %s", std::to_string(stepTo).c_str());
+        LOG(VERBOSE) << "executing step to " << stepTo;
 
         lock_guard<mutex> lk(mMut);
 
@@ -213,7 +212,7 @@
 }
 
 void TunerSession::cancelLocked() {
-    ALOGV("%s", __func__);
+    LOG(VERBOSE) << "cancelling current operations...";
 
     mThread.cancelAll();
     if (utils::getType(mCurrentProgram.primaryId) != IdentifierType::INVALID) {
@@ -222,7 +221,6 @@
 }
 
 Return<void> TunerSession::cancel() {
-    ALOGV("%s", __func__);
     lock_guard<mutex> lk(mMut);
     if (mIsClosed) return {};
 
@@ -232,7 +230,7 @@
 }
 
 Return<Result> TunerSession::startProgramListUpdates(const ProgramFilter& filter) {
-    ALOGV("%s(%s)", __func__, toString(filter).c_str());
+    LOG(DEBUG) << "requested program list updates, filter=" << toString(filter);
     lock_guard<mutex> lk(mMut);
     if (mIsClosed) return Result::INVALID_STATE;
 
@@ -259,41 +257,37 @@
 }
 
 Return<void> TunerSession::stopProgramListUpdates() {
-    ALOGV("%s", __func__);
+    LOG(DEBUG) << "requested program list updates to stop";
     return {};
 }
 
 Return<void> TunerSession::isConfigFlagSet(ConfigFlag flag, isConfigFlagSet_cb _hidl_cb) {
-    ALOGV("%s(%s)", __func__, toString(flag).c_str());
+    LOG(VERBOSE) << __func__ << " " << toString(flag);
 
     _hidl_cb(Result::NOT_SUPPORTED, false);
     return {};
 }
 
 Return<Result> TunerSession::setConfigFlag(ConfigFlag flag, bool value) {
-    ALOGV("%s(%s, %d)", __func__, toString(flag).c_str(), value);
+    LOG(VERBOSE) << __func__ << " " << toString(flag) << " " << value;
 
     return Result::NOT_SUPPORTED;
 }
 
 Return<void> TunerSession::setParameters(const hidl_vec<VendorKeyValue>& /* parameters */,
                                          setParameters_cb _hidl_cb) {
-    ALOGV("%s", __func__);
-
     _hidl_cb({});
     return {};
 }
 
 Return<void> TunerSession::getParameters(const hidl_vec<hidl_string>& /* keys */,
                                          getParameters_cb _hidl_cb) {
-    ALOGV("%s", __func__);
-
     _hidl_cb({});
     return {};
 }
 
 Return<void> TunerSession::close() {
-    ALOGV("%s", __func__);
+    LOG(DEBUG) << "closing session...";
     lock_guard<mutex> lk(mMut);
     if (mIsClosed) return {};
 
@@ -304,7 +298,7 @@
 
 std::optional<AmFmBandRange> TunerSession::getAmFmRangeLocked() const {
     if (!mIsTuneCompleted) {
-        ALOGW("tune operation in process");
+        LOG(WARNING) << "tune operation is in process";
         return {};
     }
     if (!utils::hasId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY)) return {};
diff --git a/broadcastradio/2.0/default/VirtualProgram.cpp b/broadcastradio/2.0/default/VirtualProgram.cpp
index acde704..a971927 100644
--- a/broadcastradio/2.0/default/VirtualProgram.cpp
+++ b/broadcastradio/2.0/default/VirtualProgram.cpp
@@ -13,15 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#define LOG_TAG "BcRadioDef.VirtualProgram"
-
 #include "VirtualProgram.h"
 
 #include "resources.h"
 
 #include <android-base/logging.h>
 #include <broadcastradio-utils-2x/Utils.h>
-#include <log/log.h>
 
 namespace android {
 namespace hardware {
@@ -72,7 +69,7 @@
             info.physicallyTunedTo = selectId(IdentifierType::SXM_CHANNEL);
             break;
         default:
-            LOG(FATAL) << "Unsupported program type: " << toString(pType);
+            LOG(FATAL) << "unsupported program type: " << toString(pType);
     }
 
     info.infoFlags |= ProgramInfoFlags::TUNED;
diff --git a/broadcastradio/2.0/default/VirtualRadio.cpp b/broadcastradio/2.0/default/VirtualRadio.cpp
index f601d41..0b65979 100644
--- a/broadcastradio/2.0/default/VirtualRadio.cpp
+++ b/broadcastradio/2.0/default/VirtualRadio.cpp
@@ -13,13 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#define LOG_TAG "BcRadioDef.VirtualRadio"
-//#define LOG_NDEBUG 0
-
 #include "VirtualRadio.h"
 
 #include <broadcastradio-utils-2x/Utils.h>
-#include <log/log.h>
 
 namespace android {
 namespace hardware {
diff --git a/broadcastradio/2.0/default/service.cpp b/broadcastradio/2.0/default/service.cpp
index 7e677a1..af96dad 100644
--- a/broadcastradio/2.0/default/service.cpp
+++ b/broadcastradio/2.0/default/service.cpp
@@ -13,8 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#define LOG_TAG "BcRadioDef.service"
-
 #include <android-base/logging.h>
 #include <hidl/HidlTransportSupport.h>
 
@@ -26,7 +24,9 @@
 using android::hardware::broadcastradio::V2_0::implementation::BroadcastRadio;
 using android::hardware::broadcastradio::V2_0::implementation::gAmFmRadio;
 
-int main(int /* argc */, char** /* argv */) {
+int main() {
+    android::base::SetDefaultTag("BcRadioDef");
+    android::base::SetMinimumLogSeverity(android::base::VERBOSE);
     configureRpcThreadpool(4, true);
 
     BroadcastRadio broadcastRadio(gAmFmRadio);
diff --git a/broadcastradio/2.0/vts/functional/Android.bp b/broadcastradio/2.0/vts/functional/Android.bp
index 6940bca..3e18a54 100644
--- a/broadcastradio/2.0/vts/functional/Android.bp
+++ b/broadcastradio/2.0/vts/functional/Android.bp
@@ -28,4 +28,5 @@
         "android.hardware.broadcastradio@vts-utils-lib",
         "libgmock",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/broadcastradio/2.0/vts/functional/VtsHalBroadcastradioV2_0TargetTest.cpp b/broadcastradio/2.0/vts/functional/VtsHalBroadcastradioV2_0TargetTest.cpp
index 3d7039d..e36f4d9 100644
--- a/broadcastradio/2.0/vts/functional/VtsHalBroadcastradioV2_0TargetTest.cpp
+++ b/broadcastradio/2.0/vts/functional/VtsHalBroadcastradioV2_0TargetTest.cpp
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "BcRadio.vts"
-#define LOG_NDEBUG 0
 #define EGMOCK_VERBOSE 1
 
 #include <VtsHalHidlTargetTestBase.h>
@@ -446,7 +444,7 @@
     EXPECT_EQ(Result::OK, result);
     EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged_, timeout::tune);
 
-    ALOGD("current program info: %s", toString(infoCb).c_str());
+    LOG(DEBUG) << "current program info: " << toString(infoCb);
 
     // it should tune exactly to what was requested
     auto freqs = utils::getAllIds(infoCb.selector, IdentifierType::AMFM_FREQUENCY);
@@ -514,12 +512,12 @@
     // TODO(b/69958777): see FmTune workaround
     std::this_thread::sleep_for(gTuneWorkaround);
 
-    EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged_, _);
+    EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged_, _).Times(AnyNumber());
     auto result = mSession->scan(true /* up */, true /* skip subchannel */);
     EXPECT_EQ(Result::OK, result);
     EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged_, timeout::tune);
 
-    EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged_, _);
+    EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged_, _).Times(AnyNumber());
     result = mSession->scan(false /* down */, false /* don't skip subchannel */);
     EXPECT_EQ(Result::OK, result);
     EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged_, timeout::tune);
@@ -548,7 +546,7 @@
     EXPECT_EQ(Result::OK, result);
     EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged_, timeout::tune);
 
-    EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged_, _);
+    EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged_, _).Times(AnyNumber());
     result = mSession->step(false /* down */);
     EXPECT_EQ(Result::OK, result);
     EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged_, timeout::tune);
@@ -823,11 +821,11 @@
     using android::hardware::broadcastradio::V2_0::vts::gEnv;
     using android::hardware::broadcastradio::V2_0::IBroadcastRadio;
     using android::hardware::broadcastradio::vts::BroadcastRadioHidlEnvironment;
+    android::base::SetDefaultTag("BcRadio.vts");
+    android::base::SetMinimumLogSeverity(android::base::VERBOSE);
     gEnv = new BroadcastRadioHidlEnvironment<IBroadcastRadio>;
     ::testing::AddGlobalTestEnvironment(gEnv);
     ::testing::InitGoogleTest(&argc, argv);
     gEnv->init(&argc, argv);
-    int status = RUN_ALL_TESTS();
-    ALOGI("Test result = %d", status);
-    return status;
+    return RUN_ALL_TESTS();
 }
diff --git a/broadcastradio/common/tests/Android.bp b/broadcastradio/common/tests/Android.bp
index 3ba31db..ef8733c 100644
--- a/broadcastradio/common/tests/Android.bp
+++ b/broadcastradio/common/tests/Android.bp
@@ -36,6 +36,7 @@
         "android.hardware.broadcastradio@1.1",
         "android.hardware.broadcastradio@2.0",
     ],
+    test_suites: ["general-tests"],
 }
 
 cc_test {
@@ -59,6 +60,7 @@
     shared_libs: [
         "android.hardware.broadcastradio@2.0",
     ],
+    test_suites: ["general-tests"],
 }
 
 cc_test {
@@ -73,4 +75,5 @@
         "WorkerThread_test.cpp",
     ],
     static_libs: ["android.hardware.broadcastradio@common-utils-lib"],
+    test_suites: ["general-tests"],
 }
diff --git a/broadcastradio/common/utils/Android.bp b/broadcastradio/common/utils/Android.bp
index 33ba7da..32e06d7 100644
--- a/broadcastradio/common/utils/Android.bp
+++ b/broadcastradio/common/utils/Android.bp
@@ -29,7 +29,6 @@
     export_include_dirs: ["include"],
     shared_libs: [
         "libbase",
-        "liblog",
         "libutils",
     ],
 }
diff --git a/broadcastradio/common/utils/WorkerThread.cpp b/broadcastradio/common/utils/WorkerThread.cpp
index bfcbb39..31f4d3f 100644
--- a/broadcastradio/common/utils/WorkerThread.cpp
+++ b/broadcastradio/common/utils/WorkerThread.cpp
@@ -14,13 +14,8 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "WorkerThread"
-//#define LOG_NDEBUG 0
-
 #include <broadcastradio-utils/WorkerThread.h>
 
-#include <log/log.h>
-
 namespace android {
 
 using std::chrono::milliseconds;
@@ -39,7 +34,6 @@
 WorkerThread::WorkerThread() : mIsTerminating(false), mThread(&WorkerThread::threadLoop, this) {}
 
 WorkerThread::~WorkerThread() {
-    ALOGV("%s", __func__);
     {
         lock_guard<mutex> lk(mMut);
         mIsTerminating = true;
@@ -49,8 +43,6 @@
 }
 
 void WorkerThread::schedule(function<void()> task, milliseconds delay) {
-    ALOGV("%s", __func__);
-
     auto when = steady_clock::now() + delay;
 
     lock_guard<mutex> lk(mMut);
@@ -59,14 +51,11 @@
 }
 
 void WorkerThread::cancelAll() {
-    ALOGV("%s", __func__);
-
     lock_guard<mutex> lk(mMut);
     priority_queue<Task>().swap(mTasks);  // empty queue
 }
 
 void WorkerThread::threadLoop() {
-    ALOGV("%s", __func__);
     while (!mIsTerminating) {
         unique_lock<mutex> lk(mMut);
         if (mTasks.empty()) {
diff --git a/broadcastradio/common/utils2x/Utils.cpp b/broadcastradio/common/utils2x/Utils.cpp
index f292c08..7892653 100644
--- a/broadcastradio/common/utils2x/Utils.cpp
+++ b/broadcastradio/common/utils2x/Utils.cpp
@@ -14,12 +14,10 @@
  * limitations under the License.
  */
 #define LOG_TAG "BcRadioDef.utils"
-//#define LOG_NDEBUG 0
 
 #include <broadcastradio-utils-2x/Utils.h>
 
 #include <android-base/logging.h>
-#include <log/log.h>
 
 namespace android {
 namespace hardware {
@@ -130,7 +128,7 @@
         case IdentifierType::SXM_SERVICE_ID:
             return haveEqualIds(a, b, IdentifierType::SXM_SERVICE_ID);
         default:  // includes all vendor types
-            ALOGW("Unsupported program type: %s", toString(type).c_str());
+            LOG(WARNING) << "unsupported program type: " << toString(type);
             return false;
     }
 }
@@ -166,7 +164,7 @@
         return val;
     }
 
-    ALOGW("Identifier %s not found", toString(type).c_str());
+    LOG(WARNING) << "identifier not found: " << toString(type);
     return 0;
 }
 
@@ -205,7 +203,7 @@
     auto expect = [&valid](bool condition, std::string message) {
         if (!condition) {
             valid = false;
-            ALOGE("Identifier not valid, expected %s", message.c_str());
+            LOG(ERROR) << "identifier not valid, expected " << message;
         }
     };
 
diff --git a/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/mock-timeout.h b/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/mock-timeout.h
index 1f716f1..f6cd6ae 100644
--- a/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/mock-timeout.h
+++ b/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/mock-timeout.h
@@ -29,7 +29,7 @@
  * INTERNAL IMPLEMENTATION - don't use in user code.
  */
 #if EGMOCK_VERBOSE
-#define EGMOCK_LOG_(...) ALOGV("egmock: " __VA_ARGS__)
+#define EGMOCK_LOG_(...) LOG(VERBOSE) << "egmock: " << __VA_ARGS__
 #else
 #define EGMOCK_LOG_(...)
 #endif
diff --git a/camera/common/1.0/default/CameraModule.cpp b/camera/common/1.0/default/CameraModule.cpp
index 392ebbc..08354b3 100644
--- a/camera/common/1.0/default/CameraModule.cpp
+++ b/camera/common/1.0/default/CameraModule.cpp
@@ -452,6 +452,16 @@
     return res;
 }
 
+int CameraModule::isStreamCombinationSupported(int cameraId, camera_stream_combination_t *streams) {
+    int res = INVALID_OPERATION;
+    if (mModule->is_stream_combination_supported != NULL) {
+        ATRACE_BEGIN("camera_module->is_stream_combination_supported");
+        res = mModule->is_stream_combination_supported(cameraId, streams);
+        ATRACE_END();
+    }
+    return res;
+}
+
 status_t CameraModule::filterOpenErrorCode(status_t err) {
     switch(err) {
         case NO_ERROR:
@@ -466,8 +476,8 @@
 }
 
 void CameraModule::removeCamera(int cameraId) {
-    free_camera_metadata(
-        const_cast<camera_metadata_t*>(mCameraInfoMap[cameraId].static_camera_characteristics));
+    free_camera_metadata(const_cast<camera_metadata_t*>(
+        mCameraInfoMap.valueFor(cameraId).static_camera_characteristics));
     mCameraInfoMap.removeItem(cameraId);
     mDeviceVersionMap.removeItem(cameraId);
 }
diff --git a/camera/common/1.0/default/include/CameraModule.h b/camera/common/1.0/default/include/CameraModule.h
index aee9654..ee75e72 100644
--- a/camera/common/1.0/default/include/CameraModule.h
+++ b/camera/common/1.0/default/include/CameraModule.h
@@ -66,6 +66,7 @@
     // Only used by CameraProvider
     void removeCamera(int cameraId);
     int getPhysicalCameraInfo(int physicalCameraId, camera_metadata_t **physicalInfo);
+    int isStreamCombinationSupported(int cameraId, camera_stream_combination_t *streams);
 
 private:
     // Derive camera characteristics keys defined after HAL device version
diff --git a/camera/device/3.4/default/ExternalCameraDevice.cpp b/camera/device/3.4/default/ExternalCameraDevice.cpp
index e7361dd..b96f574 100644
--- a/camera/device/3.4/default/ExternalCameraDevice.cpp
+++ b/camera/device/3.4/default/ExternalCameraDevice.cpp
@@ -48,24 +48,31 @@
 } // anonymous namespace
 
 ExternalCameraDevice::ExternalCameraDevice(
-            const std::string& cameraId, const ExternalCameraConfig& cfg) :
+        const std::string& cameraId, const ExternalCameraConfig& cfg) :
         mCameraId(cameraId),
-        mCfg(cfg) {
-
-    status_t ret = initCameraCharacteristics();
-    if (ret != OK) {
-        ALOGE("%s: init camera characteristics failed: errorno %d", __FUNCTION__, ret);
-        mInitFailed = true;
-    }
-}
+        mCfg(cfg) {}
 
 ExternalCameraDevice::~ExternalCameraDevice() {}
 
 bool ExternalCameraDevice::isInitFailed() {
+    Mutex::Autolock _l(mLock);
+    return isInitFailedLocked();
+}
+
+bool ExternalCameraDevice::isInitFailedLocked() {
+    if (!mInitialized) {
+        status_t ret = initCameraCharacteristics();
+        if (ret != OK) {
+            ALOGE("%s: init camera characteristics failed: errorno %d", __FUNCTION__, ret);
+            mInitFailed = true;
+        }
+        mInitialized = true;
+    }
     return mInitFailed;
 }
 
-Return<void> ExternalCameraDevice::getResourceCost(getResourceCost_cb _hidl_cb) {
+Return<void> ExternalCameraDevice::getResourceCost(
+        ICameraDevice::getResourceCost_cb _hidl_cb) {
     CameraResourceCost resCost;
     resCost.resourceCost = 100;
     _hidl_cb(Status::OK, resCost);
@@ -73,11 +80,11 @@
 }
 
 Return<void> ExternalCameraDevice::getCameraCharacteristics(
-        getCameraCharacteristics_cb _hidl_cb) {
+        ICameraDevice::getCameraCharacteristics_cb _hidl_cb) {
     Mutex::Autolock _l(mLock);
     V3_2::CameraMetadata hidlChars;
 
-    if (isInitFailed()) {
+    if (isInitFailedLocked()) {
         _hidl_cb(Status::INTERNAL_ERROR, hidlChars);
         return Void();
     }
@@ -94,7 +101,7 @@
 }
 
 Return<void> ExternalCameraDevice::open(
-        const sp<ICameraDeviceCallback>& callback, open_cb _hidl_cb) {
+        const sp<ICameraDeviceCallback>& callback, ICameraDevice::open_cb _hidl_cb) {
     Status status = Status::OK;
     sp<ExternalCameraDeviceSession> session = nullptr;
 
@@ -143,7 +150,7 @@
         }
     }
 
-    session = new ExternalCameraDeviceSession(
+    session = createSession(
             callback, mCfg, mSupportedFormats, mCroppingType,
             mCameraCharacteristics, mCameraId, std::move(fd));
     if (session == nullptr) {
@@ -479,52 +486,9 @@
     UPDATE(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, availableResultKeys,
            ARRAY_SIZE(availableResultKeys));
 
-    const int32_t availableCharacteristicsKeys[] = {
-        ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES,
-        ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,
-        ANDROID_CONTROL_AE_AVAILABLE_MODES,
-        ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,
-        ANDROID_CONTROL_AE_COMPENSATION_RANGE,
-        ANDROID_CONTROL_AE_COMPENSATION_STEP,
-        ANDROID_CONTROL_AE_LOCK_AVAILABLE,
-        ANDROID_CONTROL_AF_AVAILABLE_MODES,
-        ANDROID_CONTROL_AVAILABLE_EFFECTS,
-        ANDROID_CONTROL_AVAILABLE_MODES,
-        ANDROID_CONTROL_AVAILABLE_SCENE_MODES,
-        ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
-        ANDROID_CONTROL_AWB_AVAILABLE_MODES,
-        ANDROID_CONTROL_AWB_LOCK_AVAILABLE,
-        ANDROID_CONTROL_MAX_REGIONS,
-        ANDROID_FLASH_INFO_AVAILABLE,
-        ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL,
-        ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
-        ANDROID_LENS_FACING,
-        ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,
-        ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION,
-        ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES,
-        ANDROID_REQUEST_AVAILABLE_CAPABILITIES,
-        ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS,
-        ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS,
-        ANDROID_REQUEST_PARTIAL_RESULT_COUNT,
-        ANDROID_REQUEST_PIPELINE_MAX_DEPTH,
-        ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
-        ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS,
-        ANDROID_SCALER_CROPPING_TYPE,
-        ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE,
-        ANDROID_SENSOR_INFO_MAX_FRAME_DURATION,
-        ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE,
-        ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE,
-        ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,
-        ANDROID_SENSOR_ORIENTATION,
-        ANDROID_SHADING_AVAILABLE_MODES,
-        ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES,
-        ANDROID_STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES,
-        ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES,
-        ANDROID_STATISTICS_INFO_MAX_FACE_COUNT,
-        ANDROID_SYNC_MAX_LATENCY};
     UPDATE(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS,
-           availableCharacteristicsKeys,
-           ARRAY_SIZE(availableCharacteristicsKeys));
+           AVAILABLE_CHARACTERISTICS_KEYS_3_4.data(),
+           AVAILABLE_CHARACTERISTICS_KEYS_3_4.size());
 
     return OK;
 }
@@ -931,6 +895,18 @@
     }
 }
 
+sp<ExternalCameraDeviceSession> ExternalCameraDevice::createSession(
+        const sp<ICameraDeviceCallback>& cb,
+        const ExternalCameraConfig& cfg,
+        const std::vector<SupportedV4L2Format>& sortedFormats,
+        const CroppingType& croppingType,
+        const common::V1_0::helper::CameraMetadata& chars,
+        const std::string& cameraId,
+        unique_fd v4l2Fd) {
+    return new ExternalCameraDeviceSession(
+            cb, cfg, sortedFormats, croppingType, chars, cameraId, std::move(v4l2Fd));
+}
+
 }  // namespace implementation
 }  // namespace V3_4
 }  // namespace device
diff --git a/camera/device/3.4/default/ExternalCameraDeviceSession.cpp b/camera/device/3.4/default/ExternalCameraDeviceSession.cpp
index 653ad59..66b17db 100644
--- a/camera/device/3.4/default/ExternalCameraDeviceSession.cpp
+++ b/camera/device/3.4/default/ExternalCameraDeviceSession.cpp
@@ -81,6 +81,8 @@
     return locked;
 }
 
+buffer_handle_t sEmptyBuffer = nullptr;
+
 } // Anonymous namespace
 
 // Static instances
@@ -103,11 +105,8 @@
         mCroppingType(croppingType),
         mCameraId(cameraId),
         mV4l2Fd(std::move(v4l2Fd)),
-        mOutputThread(new OutputThread(this, mCroppingType)),
         mMaxThumbResolution(getMaxThumbResolution()),
-        mMaxJpegResolution(getMaxJpegResolution()) {
-    mInitFail = initialize();
-}
+        mMaxJpegResolution(getMaxJpegResolution()) {}
 
 bool ExternalCameraDeviceSession::initialize() {
     if (mV4l2Fd.get() < 0) {
@@ -142,6 +141,12 @@
             model = card;
         }
     }
+
+    initOutputThread();
+    if (mOutputThread == nullptr) {
+        ALOGE("%s: init OutputThread failed!", __FUNCTION__);
+        return true;
+    }
     mOutputThread->setExifMakeModel(make, model);
 
     status_t status = initDefaultRequests();
@@ -168,6 +173,32 @@
     return false;
 }
 
+bool ExternalCameraDeviceSession::isInitFailed() {
+    Mutex::Autolock _l(mLock);
+    if (!mInitialized) {
+        mInitFail = initialize();
+        mInitialized = true;
+    }
+    return mInitFail;
+}
+
+void ExternalCameraDeviceSession::initOutputThread() {
+    mOutputThread = new OutputThread(this, mCroppingType);
+}
+
+void ExternalCameraDeviceSession::closeOutputThread() {
+    closeOutputThreadImpl();
+}
+
+void ExternalCameraDeviceSession::closeOutputThreadImpl() {
+    if (mOutputThread) {
+        mOutputThread->flush();
+        mOutputThread->requestExit();
+        mOutputThread->join();
+        mOutputThread.clear();
+    }
+}
+
 Status ExternalCameraDeviceSession::initStatus() const {
     Mutex::Autolock _l(mLock);
     Status status = Status::OK;
@@ -181,7 +212,7 @@
 ExternalCameraDeviceSession::~ExternalCameraDeviceSession() {
     if (!isClosed()) {
         ALOGE("ExternalCameraDeviceSession deleted before close!");
-        close();
+        close(/*callerIsDtor*/true);
     }
 }
 
@@ -442,18 +473,23 @@
     return Status::OK;
 }
 
-Return<void> ExternalCameraDeviceSession::close() {
+Return<void> ExternalCameraDeviceSession::close(bool callerIsDtor) {
     Mutex::Autolock _il(mInterfaceLock);
     bool closed = isClosed();
     if (!closed) {
-        mOutputThread->flush();
-        mOutputThread->requestExit();
-        mOutputThread->join();
+        if (callerIsDtor) {
+            closeOutputThreadImpl();
+        } else {
+            closeOutputThread();
+        }
 
         Mutex::Autolock _l(mLock);
         // free all buffers
-        for(auto pair : mStreamMap) {
-            cleanupBuffersLocked(/*Stream ID*/pair.first);
+        {
+            Mutex::Autolock _l(mCbsLock);
+            for(auto pair : mStreamMap) {
+                cleanupBuffersLocked(/*Stream ID*/pair.first);
+            }
         }
         v4l2StreamOffLocked();
         ALOGV("%s: closing V4L2 camera FD %d", __FUNCTION__, mV4l2Fd.get());
@@ -463,10 +499,61 @@
     return Void();
 }
 
-Status ExternalCameraDeviceSession::importRequest(
+Status ExternalCameraDeviceSession::importRequestLocked(
+    const CaptureRequest& request,
+    hidl_vec<buffer_handle_t*>& allBufPtrs,
+    hidl_vec<int>& allFences) {
+    return importRequestLockedImpl(request, allBufPtrs, allFences);
+}
+
+Status ExternalCameraDeviceSession::importBuffer(int32_t streamId,
+        uint64_t bufId, buffer_handle_t buf,
+        /*out*/buffer_handle_t** outBufPtr,
+        bool allowEmptyBuf) {
+    Mutex::Autolock _l(mCbsLock);
+    return importBufferLocked(streamId, bufId, buf, outBufPtr, allowEmptyBuf);
+}
+
+Status ExternalCameraDeviceSession::importBufferLocked(int32_t streamId,
+        uint64_t bufId, buffer_handle_t buf,
+        /*out*/buffer_handle_t** outBufPtr,
+        bool allowEmptyBuf) {
+
+    if (buf == nullptr && bufId == BUFFER_ID_NO_BUFFER) {
+        if (allowEmptyBuf) {
+            *outBufPtr = &sEmptyBuffer;
+            return Status::OK;
+        } else {
+            ALOGE("%s: bufferId %" PRIu64 " has null buffer handle!", __FUNCTION__, bufId);
+            return Status::ILLEGAL_ARGUMENT;
+        }
+    }
+
+    CirculatingBuffers& cbs = mCirculatingBuffers[streamId];
+    if (cbs.count(bufId) == 0) {
+        if (buf == nullptr) {
+            ALOGE("%s: bufferId %" PRIu64 " has null buffer handle!", __FUNCTION__, bufId);
+            return Status::ILLEGAL_ARGUMENT;
+        }
+        // Register a newly seen buffer
+        buffer_handle_t importedBuf = buf;
+        sHandleImporter.importBuffer(importedBuf);
+        if (importedBuf == nullptr) {
+            ALOGE("%s: output buffer for stream %d is invalid!", __FUNCTION__, streamId);
+            return Status::INTERNAL_ERROR;
+        } else {
+            cbs[bufId] = importedBuf;
+        }
+    }
+    *outBufPtr = &cbs[bufId];
+    return Status::OK;
+}
+
+Status ExternalCameraDeviceSession::importRequestLockedImpl(
         const CaptureRequest& request,
         hidl_vec<buffer_handle_t*>& allBufPtrs,
-        hidl_vec<int>& allFences) {
+        hidl_vec<int>& allFences,
+        bool allowEmptyBuf) {
     size_t numOutputBufs = request.outputBuffers.size();
     size_t numBufs = numOutputBufs;
     // Validate all I/O buffers
@@ -485,26 +572,17 @@
         streamIds[i] = request.outputBuffers[i].streamId;
     }
 
-    for (size_t i = 0; i < numBufs; i++) {
-        buffer_handle_t buf = allBufs[i];
-        uint64_t bufId = allBufIds[i];
-        CirculatingBuffers& cbs = mCirculatingBuffers[streamIds[i]];
-        if (cbs.count(bufId) == 0) {
-            if (buf == nullptr) {
-                ALOGE("%s: bufferId %" PRIu64 " has null buffer handle!", __FUNCTION__, bufId);
-                return Status::ILLEGAL_ARGUMENT;
-            }
-            // Register a newly seen buffer
-            buffer_handle_t importedBuf = buf;
-            sHandleImporter.importBuffer(importedBuf);
-            if (importedBuf == nullptr) {
-                ALOGE("%s: output buffer %zu is invalid!", __FUNCTION__, i);
-                return Status::INTERNAL_ERROR;
-            } else {
-                cbs[bufId] = importedBuf;
+    {
+        Mutex::Autolock _l(mCbsLock);
+        for (size_t i = 0; i < numBufs; i++) {
+            Status st = importBufferLocked(
+                    streamIds[i], allBufIds[i], allBufs[i], &allBufPtrs[i],
+                    allowEmptyBuf);
+            if (st != Status::OK) {
+                // Detailed error logs printed in importBuffer
+                return st;
             }
         }
-        allBufPtrs[i] = &cbs[bufId];
     }
 
     // All buffers are imported. Now validate output buffer acquire fences
@@ -652,7 +730,7 @@
         }
     }
 
-    status = importRequest(request, allBufPtrs, allFences);
+    status = importRequestLocked(request, allBufPtrs, allFences);
     if (status != Status::OK) {
         return status;
     }
@@ -775,9 +853,11 @@
         result.outputBuffers[i].bufferId = req->buffers[i].bufferId;
         if (req->buffers[i].fenceTimeout) {
             result.outputBuffers[i].status = BufferStatus::ERROR;
-            native_handle_t* handle = native_handle_create(/*numFds*/1, /*numInts*/0);
-            handle->data[0] = req->buffers[i].acquireFence;
-            result.outputBuffers[i].releaseFence.setTo(handle, /*shouldOwn*/false);
+            if (req->buffers[i].acquireFence > 0) {
+                native_handle_t* handle = native_handle_create(/*numFds*/1, /*numInts*/0);
+                handle->data[0] = req->buffers[i].acquireFence;
+                result.outputBuffers[i].releaseFence.setTo(handle, /*shouldOwn*/false);
+            }
             notifyError(req->frameNumber, req->buffers[i].streamId, ErrorCode::ERROR_BUFFER);
         } else {
             result.outputBuffers[i].status = BufferStatus::OK;
@@ -1747,6 +1827,12 @@
                 (req->frameIn->mFourcc >> 24) & 0xFF);
     }
 
+    int res = requestBufferStart(req->buffers);
+    if (res != 0) {
+        ALOGE("%s: send BufferRequest failed! res %d", __FUNCTION__, res);
+        return onDeviceError("%s: failed to send buffer request!", __FUNCTION__);
+    }
+
     std::unique_lock<std::mutex> lk(mBufferLock);
     // Convert input V4L2 frame to YU12 of the same size
     // TODO: see if we can save some computation by converting to YV12 here
@@ -1759,7 +1845,7 @@
 
     // TODO: in some special case maybe we can decode jpg directly to gralloc output?
     ATRACE_BEGIN("MJPGtoI420");
-    int res = libyuv::MJPGToI420(
+    res = libyuv::MJPGToI420(
             inData, inDataSize,
             static_cast<uint8_t*>(mYu12FrameLayout.y),
             mYu12FrameLayout.yStride,
@@ -1783,10 +1869,23 @@
         return true;
     }
 
+    ATRACE_BEGIN("Wait for BufferRequest done");
+    res = waitForBufferRequestDone(&req->buffers);
+    ATRACE_END();
+
+    if (res != 0) {
+        ALOGE("%s: wait for BufferRequest done failed! res %d", __FUNCTION__, res);
+        lk.unlock();
+        return onDeviceError("%s: failed to process buffer request error!", __FUNCTION__);
+    }
+
     ALOGV("%s processing new request", __FUNCTION__);
     const int kSyncWaitTimeoutMs = 500;
     for (auto& halBuf : req->buffers) {
-        if (halBuf.acquireFence != -1) {
+        if (*(halBuf.bufPtr) == nullptr) {
+            ALOGW("%s: buffer for stream %d missing", __FUNCTION__, halBuf.streamId);
+            halBuf.fenceTimeout = true;
+        } else if (halBuf.acquireFence != -1) {
             int ret = sync_wait(halBuf.acquireFence, kSyncWaitTimeoutMs);
             if (ret) {
                 halBuf.fenceTimeout = true;
@@ -2045,7 +2144,7 @@
 }
 
 void ExternalCameraDeviceSession::updateBufferCaches(const hidl_vec<BufferCache>& cachesToRemove) {
-    Mutex::Autolock _l(mLock);
+    Mutex::Autolock _l(mCbsLock);
     for (auto& cache : cachesToRemove) {
         auto cbsIt = mCirculatingBuffers.find(cache.streamId);
         if (cbsIt == mCirculatingBuffers.end()) {
@@ -2064,7 +2163,8 @@
     }
 }
 
-bool ExternalCameraDeviceSession::isSupported(const Stream& stream) {
+bool ExternalCameraDeviceSession::isSupported(const Stream& stream,
+        const std::vector<SupportedV4L2Format>& supportedFormats) {
     int32_t ds = static_cast<int32_t>(stream.dataSpace);
     PixelFormat fmt = stream.format;
     uint32_t width = stream.width;
@@ -2107,7 +2207,7 @@
     // Assume we can convert any V4L2 format to any of supported output format for now, i.e,
     // ignoring v4l2Fmt.fourcc for now. Might need more subtle check if we support more v4l format
     // in the futrue.
-    for (const auto& v4l2Fmt : mSupportedFormats) {
+    for (const auto& v4l2Fmt : supportedFormats) {
         if (width == v4l2Fmt.width && height == v4l2Fmt.height) {
             return true;
         }
@@ -2442,11 +2542,9 @@
     mV4L2BufferReturned.notify_one();
 }
 
-Status ExternalCameraDeviceSession::configureStreams(
+Status ExternalCameraDeviceSession::isStreamCombinationSupported(
         const V3_2::StreamConfiguration& config,
-        V3_3::HalStreamConfiguration* out,
-        uint32_t blobBufferSize) {
-    ATRACE_CALL();
+        const std::vector<SupportedV4L2Format>& supportedFormats) {
     if (config.operationMode != StreamConfigurationMode::NORMAL_MODE) {
         ALOGE("%s: unsupported operation mode: %d", __FUNCTION__, config.operationMode);
         return Status::ILLEGAL_ARGUMENT;
@@ -2461,7 +2559,7 @@
     int numStallStream = 0;
     for (const auto& stream : config.streams) {
         // Check if the format/width/height combo is supported
-        if (!isSupported(stream)) {
+        if (!isSupported(stream, supportedFormats)) {
             return Status::ILLEGAL_ARGUMENT;
         }
         if (stream.format == PixelFormat::BLOB) {
@@ -2483,7 +2581,21 @@
         return Status::ILLEGAL_ARGUMENT;
     }
 
-    Status status = initStatus();
+    return Status::OK;
+}
+
+Status ExternalCameraDeviceSession::configureStreams(
+        const V3_2::StreamConfiguration& config,
+        V3_3::HalStreamConfiguration* out,
+        uint32_t blobBufferSize) {
+    ATRACE_CALL();
+
+    Status status = isStreamCombinationSupported(config, mSupportedFormats);
+    if (status != Status::OK) {
+        return status;
+    }
+
+    status = initStatus();
     if (status != Status::OK) {
         return status;
     }
@@ -2499,30 +2611,33 @@
     }
 
     Mutex::Autolock _l(mLock);
-    // Add new streams
-    for (const auto& stream : config.streams) {
-        if (mStreamMap.count(stream.id) == 0) {
-            mStreamMap[stream.id] = stream;
-            mCirculatingBuffers.emplace(stream.id, CirculatingBuffers{});
-        }
-    }
-
-    // Cleanup removed streams
-    for(auto it = mStreamMap.begin(); it != mStreamMap.end();) {
-        int id = it->first;
-        bool found = false;
+    {
+        Mutex::Autolock _l(mCbsLock);
+        // Add new streams
         for (const auto& stream : config.streams) {
-            if (id == stream.id) {
-                found = true;
-                break;
+            if (mStreamMap.count(stream.id) == 0) {
+                mStreamMap[stream.id] = stream;
+                mCirculatingBuffers.emplace(stream.id, CirculatingBuffers{});
             }
         }
-        if (!found) {
-            // Unmap all buffers of deleted stream
-            cleanupBuffersLocked(id);
-            it = mStreamMap.erase(it);
-        } else {
-            ++it;
+
+        // Cleanup removed streams
+        for(auto it = mStreamMap.begin(); it != mStreamMap.end();) {
+            int id = it->first;
+            bool found = false;
+            for (const auto& stream : config.streams) {
+                if (id == stream.id) {
+                    found = true;
+                    break;
+                }
+            }
+            if (!found) {
+                // Unmap all buffers of deleted stream
+                cleanupBuffersLocked(id);
+                it = mStreamMap.erase(it);
+            } else {
+                ++it;
+            }
         }
     }
 
diff --git a/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h b/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h
index 6e56596..9cc55cb 100644
--- a/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h
+++ b/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h
@@ -97,7 +97,7 @@
     // Call by CameraDevice to dump active device states
     void dumpState(const native_handle_t*);
     // Caller must use this method to check if CameraDeviceSession ctor failed
-    bool isInitFailed() { return mInitFail; }
+    bool isInitFailed();
     bool isClosed();
 
     // Retrieve the HIDL interface, split into its own class to avoid inheritance issues when
@@ -134,7 +134,7 @@
             ICameraDeviceSession::processCaptureRequest_cb);
 
     Return<Status> flush();
-    Return<void> close();
+    Return<void> close(bool callerIsDtor = false);
 
     Return<void> configureStreams_3_3(
             const V3_2::StreamConfiguration&,
@@ -170,10 +170,17 @@
         std::vector<HalStreamBuffer> buffers;
     };
 
+    static const uint64_t BUFFER_ID_NO_BUFFER = 0;
+
     Status constructDefaultRequestSettingsRaw(RequestTemplate type,
             V3_2::CameraMetadata *outMetadata);
 
     bool initialize();
+    // To init/close different version of output thread
+    virtual void initOutputThread();
+    virtual void closeOutputThread();
+    void closeOutputThreadImpl();
+
     Status initStatus() const;
     status_t initDefaultRequests();
     status_t fillCaptureResult(common::V1_0::helper::CameraMetadata& md, nsecs_t timestamp);
@@ -186,19 +193,40 @@
     int configureV4l2StreamLocked(const SupportedV4L2Format& fmt, double fps = 0.0);
     int v4l2StreamOffLocked();
     int setV4l2FpsLocked(double fps);
+    static Status isStreamCombinationSupported(const V3_2::StreamConfiguration& config,
+            const std::vector<SupportedV4L2Format>& supportedFormats);
 
     // TODO: change to unique_ptr for better tracking
     sp<V4L2Frame> dequeueV4l2FrameLocked(/*out*/nsecs_t* shutterTs); // Called with mLock hold
     void enqueueV4l2Frame(const sp<V4L2Frame>&);
 
     // Check if input Stream is one of supported stream setting on this device
-    bool isSupported(const Stream&);
+    static bool isSupported(const Stream& stream,
+            const std::vector<SupportedV4L2Format>& supportedFormats);
 
     // Validate and import request's output buffers and acquire fence
-    Status importRequest(
+    virtual Status importRequestLocked(
             const CaptureRequest& request,
             hidl_vec<buffer_handle_t*>& allBufPtrs,
             hidl_vec<int>& allFences);
+
+    Status importRequestLockedImpl(
+            const CaptureRequest& request,
+            hidl_vec<buffer_handle_t*>& allBufPtrs,
+            hidl_vec<int>& allFences,
+            // Optional argument for ICameraDeviceSession@3.5 impl
+            bool allowEmptyBuf = false);
+
+    Status importBuffer(int32_t streamId,
+            uint64_t bufId, buffer_handle_t buf,
+            /*out*/buffer_handle_t** outBufPtr,
+            bool allowEmptyBuf);
+
+    Status importBufferLocked(int32_t streamId,
+            uint64_t bufId, buffer_handle_t buf,
+            /*out*/buffer_handle_t** outBufPtr,
+            bool allowEmptyBuf);
+
     static void cleanupInflightFences(
             hidl_vec<int>& allFences, size_t numFences);
     void cleanupBuffersLocked(int id);
@@ -224,7 +252,7 @@
     class OutputThread : public android::Thread {
     public:
         OutputThread(wp<ExternalCameraDeviceSession> parent, CroppingType);
-        ~OutputThread();
+        virtual ~OutputThread();
 
         Status allocateIntermediateBuffers(
                 const Size& v4lSize, const Size& thumbSize,
@@ -236,7 +264,14 @@
         virtual bool threadLoop() override;
 
         void setExifMakeModel(const std::string& make, const std::string& model);
-    private:
+
+    protected:
+        // Methods to request output buffer in parallel
+        // No-op for device@3.4. Implemented in device@3.5
+        virtual int requestBufferStart(const std::vector<HalStreamBuffer>&) { return 0; }
+        virtual int waitForBufferRequestDone(
+                /*out*/std::vector<HalStreamBuffer>*) { return 0; }
+
         static const uint32_t FLEX_YUV_GENERIC = static_cast<uint32_t>('F') |
                 static_cast<uint32_t>('L') << 8 | static_cast<uint32_t>('E') << 16 |
                 static_cast<uint32_t>('X') << 24;
@@ -319,6 +354,7 @@
     //    - init failed
     //    - camera disconnected
     bool mClosed = false;
+    bool mInitialized = false;
     bool mInitFail = false;
     bool mFirstRequest = false;
     common::V1_0::helper::CameraMetadata mLatestReqSetting;
@@ -351,6 +387,8 @@
     typedef std::unordered_map<uint64_t, buffer_handle_t> CirculatingBuffers;
     // Stream ID -> circulating buffers map
     std::map<int, CirculatingBuffers> mCirculatingBuffers;
+    // Protect mCirculatingBuffers, must not lock mLock after acquiring this lock
+    mutable Mutex mCbsLock;
 
     std::mutex mAfTriggerLock; // protect mAfTrigger
     bool mAfTrigger = false;
diff --git a/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDevice_3_4.h b/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDevice_3_4.h
index ff0cfb3..719a3ed 100644
--- a/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDevice_3_4.h
+++ b/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDevice_3_4.h
@@ -25,6 +25,8 @@
 #include <hidl/MQDescriptor.h>
 #include "ExternalCameraDeviceSession.h"
 
+#include <vector>
+
 namespace android {
 namespace hardware {
 namespace camera {
@@ -49,7 +51,7 @@
 /*
  * The camera device HAL implementation is opened lazily (via the open call)
  */
-struct ExternalCameraDevice : public ICameraDevice {
+struct ExternalCameraDevice : public virtual RefBase {
 
     // Called by external camera provider HAL.
     // Provider HAL must ensure the uniqueness of CameraDevice object per cameraId, or there could
@@ -57,33 +59,54 @@
     // to keep track of all CameraDevice objects in order to notify CameraDevice when the underlying
     // camera is detached.
     ExternalCameraDevice(const std::string& cameraId, const ExternalCameraConfig& cfg);
-    ~ExternalCameraDevice();
+    virtual ~ExternalCameraDevice();
+
+    // Retrieve the HIDL interface, split into its own class to avoid inheritance issues when
+    // dealing with minor version revs and simultaneous implementation and interface inheritance
+    virtual sp<ICameraDevice> getInterface() {
+        return new TrampolineDeviceInterface_3_4(this);
+    }
 
     // Caller must use this method to check if CameraDevice ctor failed
     bool isInitFailed();
+    bool isInitFailedLocked();
 
     /* Methods from ::android::hardware::camera::device::V3_2::ICameraDevice follow. */
     // The following method can be called without opening the actual camera device
-    Return<void> getResourceCost(getResourceCost_cb _hidl_cb) override;
+    Return<void> getResourceCost(ICameraDevice::getResourceCost_cb _hidl_cb);
 
-    Return<void> getCameraCharacteristics(getCameraCharacteristics_cb _hidl_cb) override;
+    Return<void> getCameraCharacteristics(
+            ICameraDevice::getCameraCharacteristics_cb _hidl_cb);
 
-    Return<Status> setTorchMode(TorchMode) override;
+    Return<Status> setTorchMode(TorchMode);
 
     // Open the device HAL and also return a default capture session
-    Return<void> open(const sp<ICameraDeviceCallback>&, open_cb) override;
+    Return<void> open(const sp<ICameraDeviceCallback>&, ICameraDevice::open_cb);
 
     // Forward the dump call to the opened session, or do nothing
-    Return<void> dumpState(const ::android::hardware::hidl_handle&) override;
+    Return<void> dumpState(const ::android::hardware::hidl_handle&);
     /* End of Methods from ::android::hardware::camera::device::V3_2::ICameraDevice */
 
 protected:
+    // Overridden by child implementations for returning different versions of
+    // ExternalCameraDeviceSession
+    virtual sp<ExternalCameraDeviceSession> createSession(
+            const sp<ICameraDeviceCallback>&,
+            const ExternalCameraConfig& cfg,
+            const std::vector<SupportedV4L2Format>& sortedFormats,
+            const CroppingType& croppingType,
+            const common::V1_0::helper::CameraMetadata& chars,
+            const std::string& cameraId,
+            unique_fd v4l2Fd);
+
     // Init supported w/h/format/fps in mSupportedFormats. Caller still owns fd
     void initSupportedFormatsLocked(int fd);
 
+    // Calls into virtual member function. Do not use it in constructor
     status_t initCameraCharacteristics();
     // Init non-device dependent keys
-    status_t initDefaultCharsKeys(::android::hardware::camera::common::V1_0::helper::CameraMetadata*);
+    virtual status_t initDefaultCharsKeys(
+            ::android::hardware::camera::common::V1_0::helper::CameraMetadata*);
     // Init camera control chars keys. Caller still owns fd
     status_t initCameraControlsCharsKeys(int fd,
             ::android::hardware::camera::common::V1_0::helper::CameraMetadata*);
@@ -103,6 +126,7 @@
             /*inout*/std::vector<SupportedV4L2Format>* pFmts);
 
     Mutex mLock;
+    bool mInitialized = false;
     bool mInitFailed = false;
     std::string mCameraId;
     const ExternalCameraConfig& mCfg;
@@ -112,6 +136,84 @@
     wp<ExternalCameraDeviceSession> mSession = nullptr;
 
     ::android::hardware::camera::common::V1_0::helper::CameraMetadata mCameraCharacteristics;
+
+    const std::vector<int32_t> AVAILABLE_CHARACTERISTICS_KEYS_3_4 = {
+        ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES,
+        ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,
+        ANDROID_CONTROL_AE_AVAILABLE_MODES,
+        ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,
+        ANDROID_CONTROL_AE_COMPENSATION_RANGE,
+        ANDROID_CONTROL_AE_COMPENSATION_STEP,
+        ANDROID_CONTROL_AE_LOCK_AVAILABLE,
+        ANDROID_CONTROL_AF_AVAILABLE_MODES,
+        ANDROID_CONTROL_AVAILABLE_EFFECTS,
+        ANDROID_CONTROL_AVAILABLE_MODES,
+        ANDROID_CONTROL_AVAILABLE_SCENE_MODES,
+        ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
+        ANDROID_CONTROL_AWB_AVAILABLE_MODES,
+        ANDROID_CONTROL_AWB_LOCK_AVAILABLE,
+        ANDROID_CONTROL_MAX_REGIONS,
+        ANDROID_FLASH_INFO_AVAILABLE,
+        ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL,
+        ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
+        ANDROID_LENS_FACING,
+        ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,
+        ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION,
+        ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES,
+        ANDROID_REQUEST_AVAILABLE_CAPABILITIES,
+        ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS,
+        ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS,
+        ANDROID_REQUEST_PARTIAL_RESULT_COUNT,
+        ANDROID_REQUEST_PIPELINE_MAX_DEPTH,
+        ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
+        ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS,
+        ANDROID_SCALER_CROPPING_TYPE,
+        ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE,
+        ANDROID_SENSOR_INFO_MAX_FRAME_DURATION,
+        ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE,
+        ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE,
+        ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,
+        ANDROID_SENSOR_ORIENTATION,
+        ANDROID_SHADING_AVAILABLE_MODES,
+        ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES,
+        ANDROID_STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES,
+        ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES,
+        ANDROID_STATISTICS_INFO_MAX_FACE_COUNT,
+        ANDROID_SYNC_MAX_LATENCY};
+
+private:
+
+    struct TrampolineDeviceInterface_3_4 : public ICameraDevice {
+        TrampolineDeviceInterface_3_4(sp<ExternalCameraDevice> parent) :
+            mParent(parent) {}
+
+        virtual Return<void> getResourceCost(V3_2::ICameraDevice::getResourceCost_cb _hidl_cb)
+                override {
+            return mParent->getResourceCost(_hidl_cb);
+        }
+
+        virtual Return<void> getCameraCharacteristics(
+                V3_2::ICameraDevice::getCameraCharacteristics_cb _hidl_cb) override {
+            return mParent->getCameraCharacteristics(_hidl_cb);
+        }
+
+        virtual Return<Status> setTorchMode(TorchMode mode) override {
+            return mParent->setTorchMode(mode);
+        }
+
+        virtual Return<void> open(const sp<V3_2::ICameraDeviceCallback>& callback,
+                V3_2::ICameraDevice::open_cb _hidl_cb) override {
+            return mParent->open(callback, _hidl_cb);
+        }
+
+        virtual Return<void> dumpState(const hidl_handle& fd) override {
+            return mParent->dumpState(fd);
+        }
+
+    private:
+        sp<ExternalCameraDevice> mParent;
+    };
+
 };
 
 }  // namespace implementation
diff --git a/camera/device/3.5/ICameraDevice.hal b/camera/device/3.5/ICameraDevice.hal
index a77380f..d9f2837 100644
--- a/camera/device/3.5/ICameraDevice.hal
+++ b/camera/device/3.5/ICameraDevice.hal
@@ -19,6 +19,7 @@
 import android.hardware.camera.common@1.0::Status;
 import @3.2::CameraMetadata;
 import @3.2::ICameraDevice;
+import @3.4::StreamConfiguration;
 
 /**
  * Camera device interface
@@ -75,4 +76,41 @@
     getPhysicalCameraCharacteristics(string physicalCameraId)
             generates (Status status, CameraMetadata cameraCharacteristics);
 
+
+    /**
+     * isStreamCombinationSupported:
+     *
+     * Check for device support of specific camera stream combination.
+     *
+     * The streamList must contain at least one output-capable stream, and may
+     * not contain more than one input-capable stream.
+     *
+     * ------------------------------------------------------------------------
+     *
+     * Preconditions:
+     *
+     * The framework can call this method at any time before, during and
+     * after active session configuration. This means that calls must not
+     * impact the performance of pending camera requests in any way. In
+     * particular there must not be any glitches or delays during normal
+     * camera streaming.
+     *
+     * Performance requirements:
+     * This call is expected to be significantly faster than stream
+     * configuration. In general HW and SW camera settings must not be
+     * changed and there must not be a user-visible impact on camera performance.
+     *
+     * @return Status Status code for the operation, one of:
+     *     OK:
+     *          On successful stream combination query.
+     *     METHOD_NOT_SUPPORTED:
+     *          The camera device does not support stream combination query.
+     *     INTERNAL_ERROR:
+     *          The stream combination query cannot complete due to internal
+     *          error.
+     * @return true in case the stream combination is supported, false otherwise.
+     *
+     */
+    isStreamCombinationSupported(@3.4::StreamConfiguration streams)
+            generates (Status status, bool queryStatus);
 };
diff --git a/camera/device/3.5/default/Android.bp b/camera/device/3.5/default/Android.bp
index 09cf3a4..7a48865 100644
--- a/camera/device/3.5/default/Android.bp
+++ b/camera/device/3.5/default/Android.bp
@@ -20,6 +20,12 @@
     export_include_dirs: ["include/device_v3_5_impl"]
 }
 
+cc_library_headers {
+    name: "camera.device@3.5-external-impl_headers",
+    vendor: true,
+    export_include_dirs: ["include/ext_device_v3_5_impl"]
+}
+
 cc_library_shared {
     name: "camera.device@3.5-impl",
     defaults: ["hidl_defaults"],
@@ -52,3 +58,45 @@
     ],
     local_include_dirs: ["include/device_v3_5_impl"],
 }
+
+cc_library_shared {
+    name: "camera.device@3.5-external-impl",
+    defaults: ["hidl_defaults"],
+    proprietary: true,
+    vendor: true,
+    srcs: [
+        "ExternalCameraDevice.cpp",
+        "ExternalCameraDeviceSession.cpp",
+    ],
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "libutils",
+        "libcutils",
+        "camera.device@3.2-impl",
+        "camera.device@3.3-impl",
+        "camera.device@3.4-external-impl",
+        "android.hardware.camera.device@3.2",
+        "android.hardware.camera.device@3.3",
+        "android.hardware.camera.device@3.4",
+        "android.hardware.camera.device@3.5",
+        "android.hardware.camera.provider@2.4",
+        "android.hardware.graphics.mapper@2.0",
+        "liblog",
+        "libhardware",
+        "libcamera_metadata",
+        "libfmq",
+        "libsync",
+        "libyuv",
+        "libjpeg",
+        "libexif",
+        "libtinyxml2"
+    ],
+    static_libs: [
+        "android.hardware.camera.common@1.0-helper",
+    ],
+    local_include_dirs: ["include/ext_device_v3_5_impl"],
+    export_shared_lib_headers: [
+        "libfmq",
+    ],
+}
diff --git a/camera/device/3.5/default/CameraDevice.cpp b/camera/device/3.5/default/CameraDevice.cpp
index a6969af..cffda4e 100644
--- a/camera/device/3.5/default/CameraDevice.cpp
+++ b/camera/device/3.5/default/CameraDevice.cpp
@@ -95,6 +95,57 @@
     return Void();
 }
 
+Return<void> CameraDevice::isStreamCombinationSupported(const V3_4::StreamConfiguration& streams,
+        V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb) {
+    Status status;
+    bool streamsSupported = false;
+
+    // Require module 2.5+ version.
+    if (mModule->getModuleApiVersion() < CAMERA_MODULE_API_VERSION_2_5) {
+        ALOGE("%s: is_stream_combination_supported must be called on camera module 2.5 or "\
+                "newer", __FUNCTION__);
+        status = Status::INTERNAL_ERROR;
+    } else {
+        camera_stream_combination_t streamComb{};
+        streamComb.operation_mode = static_cast<uint32_t> (streams.operationMode);
+        streamComb.num_streams = streams.streams.size();
+        camera_stream_t *streamBuffer  = new camera_stream_t[streamComb.num_streams];
+
+        size_t i = 0;
+        for (const auto &it : streams.streams) {
+            streamBuffer[i].stream_type = static_cast<int> (it.v3_2.streamType);
+            streamBuffer[i].width = it.v3_2.width;
+            streamBuffer[i].height = it.v3_2.height;
+            streamBuffer[i].format = static_cast<int> (it.v3_2.format);
+            streamBuffer[i].data_space = static_cast<android_dataspace_t> (it.v3_2.dataSpace);
+            streamBuffer[i].usage = static_cast<uint32_t> (it.v3_2.usage);
+            streamBuffer[i].physical_camera_id = it.physicalCameraId.c_str();
+            streamBuffer[i++].rotation = static_cast<int> (it.v3_2.rotation);
+        }
+        streamComb.streams = streamBuffer;
+        auto res = mModule->isStreamCombinationSupported(mCameraIdInt, &streamComb);
+        switch (res) {
+            case NO_ERROR:
+                streamsSupported = true;
+                status = Status::OK;
+                break;
+            case BAD_VALUE:
+                status = Status::OK;
+                break;
+            case INVALID_OPERATION:
+                status = Status::METHOD_NOT_SUPPORTED;
+                break;
+            default:
+                ALOGE("%s: Unexpected error: %d", __FUNCTION__, res);
+                status = Status::INTERNAL_ERROR;
+        };
+        delete [] streamBuffer;
+    }
+
+    _hidl_cb(status, streamsSupported);
+    return Void();
+}
+
 // End of methods from ::android::hardware::camera::device::V3_2::ICameraDevice.
 
 } // namespace implementation
diff --git a/camera/device/3.5/default/ExternalCameraDevice.cpp b/camera/device/3.5/default/ExternalCameraDevice.cpp
new file mode 100644
index 0000000..6a0b51e
--- /dev/null
+++ b/camera/device/3.5/default/ExternalCameraDevice.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2018 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 "ExtCamDev@3.5"
+//#define LOG_NDEBUG 0
+#include <log/log.h>
+
+#include "ExternalCameraDevice_3_5.h"
+
+namespace android {
+namespace hardware {
+namespace camera {
+namespace device {
+namespace V3_5 {
+namespace implementation {
+
+ExternalCameraDevice::ExternalCameraDevice(
+        const std::string& cameraId, const ExternalCameraConfig& cfg) :
+        V3_4::implementation::ExternalCameraDevice(cameraId, cfg) {}
+
+ExternalCameraDevice::~ExternalCameraDevice() {}
+
+Return<void> ExternalCameraDevice::getPhysicalCameraCharacteristics(const hidl_string&,
+        V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb) {
+    CameraMetadata cameraCharacteristics;
+    // External camera HAL doesn't support physical camera functions
+    _hidl_cb(Status::ILLEGAL_ARGUMENT, cameraCharacteristics);
+    return Void();
+}
+
+sp<V3_4::implementation::ExternalCameraDeviceSession> ExternalCameraDevice::createSession(
+        const sp<V3_2::ICameraDeviceCallback>& cb,
+        const ExternalCameraConfig& cfg,
+        const std::vector<SupportedV4L2Format>& sortedFormats,
+        const CroppingType& croppingType,
+        const common::V1_0::helper::CameraMetadata& chars,
+        const std::string& cameraId,
+        unique_fd v4l2Fd) {
+    return new ExternalCameraDeviceSession(
+            cb, cfg, sortedFormats, croppingType, chars, cameraId, std::move(v4l2Fd));
+}
+
+#define UPDATE(tag, data, size)                    \
+do {                                               \
+  if (metadata->update((tag), (data), (size))) {   \
+    ALOGE("Update " #tag " failed!");              \
+    return -EINVAL;                                \
+  }                                                \
+} while (0)
+
+status_t ExternalCameraDevice::initDefaultCharsKeys(
+        ::android::hardware::camera::common::V1_0::helper::CameraMetadata* metadata) {
+    status_t res =
+            V3_4::implementation::ExternalCameraDevice::initDefaultCharsKeys(metadata);
+
+    if (res != OK) {
+        return res;
+    }
+
+    const uint8_t bufMgrVer = ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_HIDL_DEVICE_3_5;
+    UPDATE(ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION, &bufMgrVer, 1);
+
+    std::vector<int> availableCharacteristicsKeys = AVAILABLE_CHARACTERISTICS_KEYS_3_4;
+    availableCharacteristicsKeys.reserve(availableCharacteristicsKeys.size() +
+            EXTRA_CHARACTERISTICS_KEYS_3_5.size());
+    for (const auto& key : EXTRA_CHARACTERISTICS_KEYS_3_5) {
+        availableCharacteristicsKeys.push_back(key);
+    }
+    UPDATE(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS,
+           availableCharacteristicsKeys.data(),
+           availableCharacteristicsKeys.size());
+
+    return OK;
+}
+
+Return<void> ExternalCameraDevice::isStreamCombinationSupported(
+        const V3_4::StreamConfiguration& streams,
+        V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb) {
+
+    if (isInitFailed()) {
+        ALOGE("%s: camera %s. camera init failed!", __FUNCTION__, mCameraId.c_str());
+        _hidl_cb(Status::INTERNAL_ERROR, false);
+        return Void();
+    }
+
+    hidl_vec<V3_2::Stream> streamsV3_2(streams.streams.size());
+    size_t i = 0;
+    for (const auto& it : streams.streams) {
+        streamsV3_2[i++] = it.v3_2;
+    }
+    V3_2::StreamConfiguration streamConfig = {streamsV3_2, streams.operationMode};
+    auto status = ExternalCameraDeviceSession::isStreamCombinationSupported(streamConfig,
+            mSupportedFormats);
+    _hidl_cb(Status::OK, Status::OK == status);
+    return Void();
+}
+#undef UPDATE
+
+}  // namespace implementation
+}  // namespace V3_5
+}  // namespace device
+}  // namespace camera
+}  // namespace hardware
+}  // namespace android
+
diff --git a/camera/device/3.5/default/ExternalCameraDeviceSession.cpp b/camera/device/3.5/default/ExternalCameraDeviceSession.cpp
new file mode 100644
index 0000000..ae7c45e
--- /dev/null
+++ b/camera/device/3.5/default/ExternalCameraDeviceSession.cpp
@@ -0,0 +1,303 @@
+/*
+ * Copyright (C) 2018 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 "ExtCamDevSsn@3.5"
+#include <android/log.h>
+
+#include <utils/Trace.h>
+#include "ExternalCameraDeviceSession.h"
+
+namespace android {
+namespace hardware {
+namespace camera {
+namespace device {
+namespace V3_5 {
+namespace implementation {
+
+ExternalCameraDeviceSession::ExternalCameraDeviceSession(
+        const sp<V3_2::ICameraDeviceCallback>& callback,
+        const ExternalCameraConfig& cfg,
+        const std::vector<SupportedV4L2Format>& sortedFormats,
+        const CroppingType& croppingType,
+        const common::V1_0::helper::CameraMetadata& chars,
+        const std::string& cameraId,
+        unique_fd v4l2Fd) :
+        V3_4::implementation::ExternalCameraDeviceSession(
+                callback, cfg, sortedFormats, croppingType, chars, cameraId, std::move(v4l2Fd)) {
+
+    mCallback_3_5 = nullptr;
+
+    auto castResult = V3_5::ICameraDeviceCallback::castFrom(callback);
+    if (castResult.isOk()) {
+        sp<V3_5::ICameraDeviceCallback> callback3_5 = castResult;
+        if (callback3_5 != nullptr) {
+            mCallback_3_5 = callback3_5;
+        }
+    }
+
+    if (mCallback_3_5 != nullptr) {
+        mSupportBufMgr = true;
+    }
+}
+
+ExternalCameraDeviceSession::~ExternalCameraDeviceSession() {
+    closeOutputThreadImpl();
+}
+
+Return<void> ExternalCameraDeviceSession::configureStreams_3_5(
+        const StreamConfiguration& requestedConfiguration,
+        ICameraDeviceSession::configureStreams_3_5_cb _hidl_cb)  {
+    return configureStreams_3_4(requestedConfiguration.v3_4, _hidl_cb);
+}
+
+Return<void> ExternalCameraDeviceSession::signalStreamFlush(
+        const hidl_vec<int32_t>& /*streamIds*/, uint32_t /*streamConfigCounter*/) {
+    return Void();
+}
+
+Status ExternalCameraDeviceSession::importRequestLocked(
+        const CaptureRequest& request,
+        hidl_vec<buffer_handle_t*>& allBufPtrs,
+        hidl_vec<int>& allFences) {
+    if (mSupportBufMgr) {
+        return importRequestLockedImpl(request, allBufPtrs, allFences, /*allowEmptyBuf*/ true);
+    }
+    return importRequestLockedImpl(request, allBufPtrs, allFences, /*allowEmptyBuf*/ false);
+}
+
+
+ExternalCameraDeviceSession::BufferRequestThread::BufferRequestThread(
+        wp<ExternalCameraDeviceSession> parent,
+        sp<V3_5::ICameraDeviceCallback> callbacks) :
+        mParent(parent),
+        mCallbacks(callbacks) {}
+
+int ExternalCameraDeviceSession::BufferRequestThread::requestBufferStart(
+        const std::vector<HalStreamBuffer>& bufReqs) {
+    if (bufReqs.empty()) {
+        ALOGE("%s: bufReqs is empty!", __FUNCTION__);
+        return -1;
+    }
+
+    {
+        std::lock_guard<std::mutex> lk(mLock);
+        if (mRequestingBuffer) {
+            ALOGE("%s: BufferRequestThread does not support more than one concurrent request!",
+                    __FUNCTION__);
+            return -1;
+        }
+
+        mBufferReqs = bufReqs;
+        mRequestingBuffer = true;
+    }
+    mRequestCond.notify_one();
+    return 0;
+}
+
+int ExternalCameraDeviceSession::BufferRequestThread::waitForBufferRequestDone(
+        std::vector<HalStreamBuffer>* outBufReq) {
+    std::unique_lock<std::mutex> lk(mLock);
+    if (!mRequestingBuffer) {
+        ALOGE("%s: no pending buffer request!", __FUNCTION__);
+        return -1;
+    }
+
+    if (mPendingReturnBufferReqs.empty()) {
+        std::chrono::milliseconds timeout = std::chrono::milliseconds(kReqProcTimeoutMs);
+        auto st = mRequestDoneCond.wait_for(lk, timeout);
+        if (st == std::cv_status::timeout) {
+            ALOGE("%s: wait for buffer request finish timeout!", __FUNCTION__);
+            return -1;
+        }
+    }
+    mRequestingBuffer = false;
+    *outBufReq = std::move(mPendingReturnBufferReqs);
+    mPendingReturnBufferReqs.clear();
+    return 0;
+}
+
+void ExternalCameraDeviceSession::BufferRequestThread::waitForNextRequest() {
+    ATRACE_CALL();
+    std::unique_lock<std::mutex> lk(mLock);
+    int waitTimes = 0;
+    while (mBufferReqs.empty()) {
+        if (exitPending()) {
+            return;
+        }
+        std::chrono::milliseconds timeout = std::chrono::milliseconds(kReqWaitTimeoutMs);
+        auto st = mRequestCond.wait_for(lk, timeout);
+        if (st == std::cv_status::timeout) {
+            waitTimes++;
+            if (waitTimes == kReqWaitTimesWarn) {
+                // BufferRequestThread just wait forever for new buffer request
+                // But it will print some periodic warning indicating it's waiting
+                ALOGV("%s: still waiting for new buffer request", __FUNCTION__);
+                waitTimes = 0;
+            }
+        }
+    }
+
+    // Fill in hidl BufferRequest
+    mHalBufferReqs.resize(mBufferReqs.size());
+    for (size_t i = 0; i < mHalBufferReqs.size(); i++) {
+        mHalBufferReqs[i].streamId = mBufferReqs[i].streamId;
+        mHalBufferReqs[i].numBuffersRequested = 1;
+    }
+}
+
+bool ExternalCameraDeviceSession::BufferRequestThread::threadLoop() {
+    waitForNextRequest();
+    if (exitPending()) {
+        return false;
+    }
+
+    ATRACE_BEGIN("HIDL requestStreamBuffers");
+    BufferRequestStatus status;
+    hidl_vec<StreamBufferRet> bufRets;
+    auto err = mCallbacks->requestStreamBuffers(mHalBufferReqs,
+            [&status, &bufRets]
+            (BufferRequestStatus s, const hidl_vec<StreamBufferRet>& rets) {
+                status = s;
+                bufRets = std::move(rets);
+            });
+    ATRACE_END();
+    if (!err.isOk()) {
+        ALOGE("%s: Transaction error: %s", __FUNCTION__, err.description().c_str());
+        return false;
+    }
+
+    std::unique_lock<std::mutex> lk(mLock);
+    if (status == BufferRequestStatus::OK || status == BufferRequestStatus::FAILED_PARTIAL) {
+        if (bufRets.size() != mHalBufferReqs.size()) {
+            ALOGE("%s: expect %zu buffer requests returned, only got %zu",
+                    __FUNCTION__, mHalBufferReqs.size(), bufRets.size());
+            return false;
+        }
+
+        auto parent = mParent.promote();
+        if (parent == nullptr) {
+            ALOGE("%s: session has been disconnected!", __FUNCTION__);
+            return false;
+        }
+
+        hidl_vec<int> importedFences;
+        importedFences.resize(bufRets.size());
+        for (size_t i = 0; i < bufRets.size(); i++) {
+            int streamId = bufRets[i].streamId;
+            switch (bufRets[i].val.getDiscriminator()) {
+                case StreamBuffersVal::hidl_discriminator::error:
+                    continue;
+                case StreamBuffersVal::hidl_discriminator::buffers: {
+                    const hidl_vec<V3_2::StreamBuffer>& hBufs = bufRets[i].val.buffers();
+                    if (hBufs.size() != 1) {
+                        ALOGE("%s: expect 1 buffer returned, got %zu!", __FUNCTION__, hBufs.size());
+                        return false;
+                    }
+                    const V3_2::StreamBuffer& hBuf = hBufs[0];
+
+                    mBufferReqs[i].bufferId = hBuf.bufferId;
+                    // TODO: create a batch import API so we don't need to lock/unlock mCbsLock
+                    // repeatedly?
+                    lk.unlock();
+                    Status s = parent->importBuffer(streamId,
+                            hBuf.bufferId, hBuf.buffer.getNativeHandle(),
+                            /*out*/&mBufferReqs[i].bufPtr,
+                            /*allowEmptyBuf*/false);
+                    lk.lock();
+
+                    if (s != Status::OK) {
+                        ALOGE("%s: stream %d import buffer failed!", __FUNCTION__, streamId);
+                        cleanupInflightFences(importedFences, i - 1);
+                        return false;
+                    }
+                    if (!sHandleImporter.importFence(hBuf.acquireFence,
+                            mBufferReqs[i].acquireFence)) {
+                        ALOGE("%s: stream %d import fence failed!", __FUNCTION__, streamId);
+                        cleanupInflightFences(importedFences, i - 1);
+                        return false;
+                    }
+                    importedFences[i] = mBufferReqs[i].acquireFence;
+                }
+                break;
+                default:
+                    ALOGE("%s: unkown StreamBuffersVal discrimator!", __FUNCTION__);
+                    return false;
+            }
+        }
+    } else {
+        ALOGE("%s: requestStreamBuffers call failed!", __FUNCTION__);
+    }
+
+    mPendingReturnBufferReqs = std::move(mBufferReqs);
+    mBufferReqs.clear();
+
+    lk.unlock();
+    mRequestDoneCond.notify_one();
+    return true;
+}
+
+void ExternalCameraDeviceSession::initOutputThread() {
+    if (mSupportBufMgr) {
+        mBufferRequestThread = new BufferRequestThread(this, mCallback_3_5);
+        mBufferRequestThread->run("ExtCamBufReq", PRIORITY_DISPLAY);
+    }
+    mOutputThread = new OutputThread(this, mCroppingType, mBufferRequestThread);
+}
+
+void ExternalCameraDeviceSession::closeOutputThreadImpl() {
+    if (mBufferRequestThread) {
+        mBufferRequestThread->requestExit();
+        mBufferRequestThread->join();
+        mBufferRequestThread.clear();
+    }
+}
+
+void ExternalCameraDeviceSession::closeOutputThread() {
+    closeOutputThreadImpl();
+    V3_4::implementation::ExternalCameraDeviceSession::closeOutputThread();
+}
+
+ExternalCameraDeviceSession::OutputThread::OutputThread(
+        wp<ExternalCameraDeviceSession> parent,
+        CroppingType ct,
+        sp<BufferRequestThread> bufReqThread) :
+        V3_4::implementation::ExternalCameraDeviceSession::OutputThread(parent, ct),
+        mBufferRequestThread(bufReqThread) {}
+
+ExternalCameraDeviceSession::OutputThread::~OutputThread() {}
+
+int ExternalCameraDeviceSession::OutputThread::requestBufferStart(
+        const std::vector<HalStreamBuffer>& bufs) {
+    if (mBufferRequestThread != nullptr) {
+        return mBufferRequestThread->requestBufferStart(bufs);
+    }
+    return 0;
+}
+
+int ExternalCameraDeviceSession::OutputThread::waitForBufferRequestDone(
+        /*out*/std::vector<HalStreamBuffer>* outBufs) {
+    if (mBufferRequestThread != nullptr) {
+        return mBufferRequestThread->waitForBufferRequestDone(outBufs);
+    }
+    return 0;
+}
+
+} // namespace implementation
+}  // namespace V3_5
+}  // namespace device
+}  // namespace camera
+}  // namespace hardware
+}  // namespace android
diff --git a/camera/device/3.5/default/include/device_v3_5_impl/CameraDevice_3_5.h b/camera/device/3.5/default/include/device_v3_5_impl/CameraDevice_3_5.h
index 6bdc60f..76c8cf8 100644
--- a/camera/device/3.5/default/include/device_v3_5_impl/CameraDevice_3_5.h
+++ b/camera/device/3.5/default/include/device_v3_5_impl/CameraDevice_3_5.h
@@ -64,6 +64,10 @@
     Return<void> getPhysicalCameraCharacteristics(const hidl_string& physicalCameraId,
             V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb);
 
+    Return<void> isStreamCombinationSupported(
+            const V3_4::StreamConfiguration& streams,
+            V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb);
+
 private:
     struct TrampolineDeviceInterface_3_5 : public ICameraDevice {
         TrampolineDeviceInterface_3_5(sp<CameraDevice> parent) :
@@ -96,6 +100,13 @@
                 V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb) override {
             return mParent->getPhysicalCameraCharacteristics(physicalCameraId, _hidl_cb);
         }
+
+        virtual Return<void> isStreamCombinationSupported(
+                const V3_4::StreamConfiguration& streams,
+                V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb) override {
+            return mParent->isStreamCombinationSupported(streams, _hidl_cb);
+        }
+
     private:
         sp<CameraDevice> mParent;
     };
diff --git a/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDeviceSession.h b/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDeviceSession.h
new file mode 100644
index 0000000..aa119fc
--- /dev/null
+++ b/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDeviceSession.h
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HARDWARE_CAMERA_DEVICE_V3_5_EXTCAMERADEVICE3SESSION_H
+#define ANDROID_HARDWARE_CAMERA_DEVICE_V3_5_EXTCAMERADEVICE3SESSION_H
+
+#include <android/hardware/camera/device/3.5/ICameraDeviceCallback.h>
+#include <android/hardware/camera/device/3.5/ICameraDeviceSession.h>
+#include <../../3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h>
+
+namespace android {
+namespace hardware {
+namespace camera {
+namespace device {
+namespace V3_5 {
+namespace implementation {
+
+using ::android::hardware::camera::device::V3_2::BufferCache;
+using ::android::hardware::camera::device::V3_5::BufferRequest;
+using ::android::hardware::camera::device::V3_5::BufferRequestStatus;
+using ::android::hardware::camera::device::V3_2::BufferStatus;
+using ::android::hardware::camera::device::V3_2::CameraMetadata;
+using ::android::hardware::camera::device::V3_2::CaptureRequest;
+using ::android::hardware::camera::device::V3_2::CaptureResult;
+using ::android::hardware::camera::device::V3_2::ErrorCode;
+using ::android::hardware::camera::device::V3_5::ICameraDeviceCallback;
+using ::android::hardware::camera::device::V3_2::MsgType;
+using ::android::hardware::camera::device::V3_2::NotifyMsg;
+using ::android::hardware::camera::device::V3_2::RequestTemplate;
+using ::android::hardware::camera::device::V3_2::Stream;
+using ::android::hardware::camera::device::V3_5::StreamConfiguration;
+using ::android::hardware::camera::device::V3_2::StreamConfigurationMode;
+using ::android::hardware::camera::device::V3_2::StreamRotation;
+using ::android::hardware::camera::device::V3_2::StreamType;
+using ::android::hardware::camera::device::V3_2::DataspaceFlags;
+using ::android::hardware::camera::device::V3_2::CameraBlob;
+using ::android::hardware::camera::device::V3_2::CameraBlobId;
+using ::android::hardware::camera::device::V3_4::HalStreamConfiguration;
+using ::android::hardware::camera::device::V3_5::ICameraDeviceSession;
+using ::android::hardware::camera::common::V1_0::Status;
+using ::android::hardware::camera::common::V1_0::helper::HandleImporter;
+using ::android::hardware::camera::common::V1_0::helper::ExifUtils;
+using ::android::hardware::camera::external::common::ExternalCameraConfig;
+using ::android::hardware::camera::external::common::Size;
+using ::android::hardware::camera::external::common::SizeHasher;
+using ::android::hardware::graphics::common::V1_0::BufferUsage;
+using ::android::hardware::graphics::common::V1_0::Dataspace;
+using ::android::hardware::graphics::common::V1_0::PixelFormat;
+using ::android::hardware::kSynchronizedReadWrite;
+using ::android::hardware::MessageQueue;
+using ::android::hardware::MQDescriptorSync;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+using ::android::Mutex;
+using ::android::base::unique_fd;
+
+using ::android::hardware::camera::device::V3_4::implementation::SupportedV4L2Format;
+using ::android::hardware::camera::device::V3_4::implementation::CroppingType;
+
+struct ExternalCameraDeviceSession : public V3_4::implementation::ExternalCameraDeviceSession {
+
+    ExternalCameraDeviceSession(const sp<V3_2::ICameraDeviceCallback>&,
+            const ExternalCameraConfig& cfg,
+            const std::vector<SupportedV4L2Format>& sortedFormats,
+            const CroppingType& croppingType,
+            const common::V1_0::helper::CameraMetadata& chars,
+            const std::string& cameraId,
+            unique_fd v4l2Fd);
+    virtual ~ExternalCameraDeviceSession();
+
+    // Retrieve the HIDL interface, split into its own class to avoid inheritance issues when
+    // dealing with minor version revs and simultaneous implementation and interface inheritance
+    virtual sp<V3_4::ICameraDeviceSession> getInterface() override {
+        return new TrampolineSessionInterface_3_5(this);
+    }
+
+    static Status isStreamCombinationSupported(const V3_2::StreamConfiguration& config,
+            const std::vector<SupportedV4L2Format>& supportedFormats) {
+        return V3_4::implementation::ExternalCameraDeviceSession::isStreamCombinationSupported(
+                config, supportedFormats);
+    }
+
+protected:
+    // Methods from v3.4 and earlier will trampoline to inherited implementation
+    Return<void> configureStreams_3_5(
+            const StreamConfiguration& requestedConfiguration,
+            ICameraDeviceSession::configureStreams_3_5_cb _hidl_cb);
+
+    Return<void> signalStreamFlush(
+            const hidl_vec<int32_t>& requests,
+            uint32_t streamConfigCounter);
+
+    virtual void initOutputThread() override;
+    virtual void closeOutputThread() override;
+    void closeOutputThreadImpl();
+
+    virtual Status importRequestLocked(
+            const CaptureRequest& request,
+            hidl_vec<buffer_handle_t*>& allBufPtrs,
+            hidl_vec<int>& allFences) override;
+
+    class BufferRequestThread : public android::Thread {
+    public:
+        BufferRequestThread(
+                wp<ExternalCameraDeviceSession> parent,
+                sp<V3_5::ICameraDeviceCallback> callbacks);
+
+        int requestBufferStart(const std::vector<HalStreamBuffer>&);
+        int waitForBufferRequestDone(
+                /*out*/std::vector<HalStreamBuffer>*);
+
+        virtual bool threadLoop() override;
+
+    private:
+        void waitForNextRequest();
+
+        const wp<ExternalCameraDeviceSession> mParent;
+        const sp<V3_5::ICameraDeviceCallback> mCallbacks;
+
+        std::mutex mLock;
+        bool mRequestingBuffer = false;
+
+        std::vector<HalStreamBuffer> mBufferReqs;
+        std::vector<HalStreamBuffer> mPendingReturnBufferReqs;
+        // mHalBufferReqs is not under mLock protection during the HIDL transaction
+        hidl_vec<BufferRequest>      mHalBufferReqs;
+
+        // request buffers takes much less time in steady state, but can take much longer
+        // when requesting 1st buffer from a stream.
+        // TODO: consider a separate timeout for new vs. steady state?
+        // TODO: or make sure framework is warming up the pipeline during configure new stream?
+        static const int kReqProcTimeoutMs = 66;
+
+        static const int kReqWaitTimeoutMs = 33;
+        static const int kReqWaitTimesWarn = 90;  // 33ms * 90 ~= 3 sec
+        std::condition_variable mRequestCond;     // signaled when a new buffer request incoming
+        std::condition_variable mRequestDoneCond; // signaled when a request is done
+    };
+
+    sp<BufferRequestThread> mBufferRequestThread;
+
+    class OutputThread :
+            public V3_4::implementation::ExternalCameraDeviceSession::OutputThread {
+    public:
+        // TODO: pass buffer request thread to OutputThread ctor
+        OutputThread(wp<ExternalCameraDeviceSession> parent, CroppingType,
+                sp<BufferRequestThread> bufReqThread);
+        virtual ~OutputThread();
+
+    protected:
+        // Methods to request output buffer in parallel
+        virtual int requestBufferStart(const std::vector<HalStreamBuffer>&) override;
+        virtual int waitForBufferRequestDone(
+                /*out*/std::vector<HalStreamBuffer>*) override;
+
+        const sp<BufferRequestThread> mBufferRequestThread;
+    };
+
+    sp<V3_5::ICameraDeviceCallback> mCallback_3_5;
+    bool mSupportBufMgr;
+
+private:
+
+    struct TrampolineSessionInterface_3_5 : public ICameraDeviceSession {
+        TrampolineSessionInterface_3_5(sp<ExternalCameraDeviceSession> parent) :
+                mParent(parent) {}
+
+        virtual Return<void> constructDefaultRequestSettings(
+                RequestTemplate type,
+                V3_3::ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb) override {
+            return mParent->constructDefaultRequestSettings(type, _hidl_cb);
+        }
+
+        virtual Return<void> configureStreams(
+                const V3_2::StreamConfiguration& requestedConfiguration,
+                V3_3::ICameraDeviceSession::configureStreams_cb _hidl_cb) override {
+            return mParent->configureStreams(requestedConfiguration, _hidl_cb);
+        }
+
+        virtual Return<void> processCaptureRequest(const hidl_vec<V3_2::CaptureRequest>& requests,
+                const hidl_vec<V3_2::BufferCache>& cachesToRemove,
+                V3_3::ICameraDeviceSession::processCaptureRequest_cb _hidl_cb) override {
+            return mParent->processCaptureRequest(requests, cachesToRemove, _hidl_cb);
+        }
+
+        virtual Return<void> getCaptureRequestMetadataQueue(
+                V3_3::ICameraDeviceSession::getCaptureRequestMetadataQueue_cb _hidl_cb) override  {
+            return mParent->getCaptureRequestMetadataQueue(_hidl_cb);
+        }
+
+        virtual Return<void> getCaptureResultMetadataQueue(
+                V3_3::ICameraDeviceSession::getCaptureResultMetadataQueue_cb _hidl_cb) override  {
+            return mParent->getCaptureResultMetadataQueue(_hidl_cb);
+        }
+
+        virtual Return<Status> flush() override {
+            return mParent->flush();
+        }
+
+        virtual Return<void> close() override {
+            return mParent->close();
+        }
+
+        virtual Return<void> configureStreams_3_3(
+                const V3_2::StreamConfiguration& requestedConfiguration,
+                configureStreams_3_3_cb _hidl_cb) override {
+            return mParent->configureStreams_3_3(requestedConfiguration, _hidl_cb);
+        }
+
+        virtual Return<void> configureStreams_3_4(
+                const V3_4::StreamConfiguration& requestedConfiguration,
+                configureStreams_3_4_cb _hidl_cb) override {
+            return mParent->configureStreams_3_4(requestedConfiguration, _hidl_cb);
+        }
+
+        virtual Return<void> processCaptureRequest_3_4(const hidl_vec<V3_4::CaptureRequest>& requests,
+                const hidl_vec<V3_2::BufferCache>& cachesToRemove,
+                ICameraDeviceSession::processCaptureRequest_3_4_cb _hidl_cb) override {
+            return mParent->processCaptureRequest_3_4(requests, cachesToRemove, _hidl_cb);
+        }
+
+        virtual Return<void> configureStreams_3_5(
+                const StreamConfiguration& requestedConfiguration,
+                configureStreams_3_5_cb _hidl_cb) override {
+            return mParent->configureStreams_3_5(requestedConfiguration, _hidl_cb);
+        }
+
+        virtual Return<void> signalStreamFlush(
+                const hidl_vec<int32_t>& requests,
+                uint32_t streamConfigCounter) override {
+            return mParent->signalStreamFlush(requests, streamConfigCounter);
+        }
+
+    private:
+        sp<ExternalCameraDeviceSession> mParent;
+    };
+};
+
+}  // namespace implementation
+}  // namespace V3_5
+}  // namespace device
+}  // namespace camera
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_CAMERA_DEVICE_V3_5_EXTCAMERADEVICE3SESSION_H
diff --git a/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDevice_3_5.h b/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDevice_3_5.h
new file mode 100644
index 0000000..b73490c
--- /dev/null
+++ b/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDevice_3_5.h
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HARDWARE_CAMERA_DEVICE_V3_5_EXTCAMERADEVICE_H
+#define ANDROID_HARDWARE_CAMERA_DEVICE_V3_5_EXTCAMERADEVICE_H
+
+#include "utils/Mutex.h"
+#include "CameraMetadata.h"
+
+#include <android/hardware/camera/device/3.5/ICameraDevice.h>
+#include <android/hardware/camera/device/3.5/ICameraDeviceCallback.h>
+#include <hidl/Status.h>
+#include <hidl/MQDescriptor.h>
+#include "ExternalCameraDeviceSession.h"
+#include <../../../../3.4/default/include/ext_device_v3_4_impl/ExternalCameraDevice_3_4.h>
+
+namespace android {
+namespace hardware {
+namespace camera {
+namespace device {
+namespace V3_5 {
+namespace implementation {
+
+using namespace ::android::hardware::camera::device;
+using ::android::hardware::camera::device::V3_5::ICameraDevice;
+using ::android::hardware::camera::common::V1_0::CameraResourceCost;
+using ::android::hardware::camera::common::V1_0::TorchMode;
+using ::android::hardware::camera::common::V1_0::Status;
+using ::android::hardware::camera::external::common::ExternalCameraConfig;
+using ::android::hardware::camera::external::common::Size;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+/*
+ * The camera device HAL implementation is opened lazily (via the open call)
+ */
+struct ExternalCameraDevice : public V3_4::implementation::ExternalCameraDevice {
+
+    // Called by external camera provider HAL.
+    // Provider HAL must ensure the uniqueness of CameraDevice object per cameraId, or there could
+    // be multiple CameraDevice trying to access the same physical camera.  Also, provider will have
+    // to keep track of all CameraDevice objects in order to notify CameraDevice when the underlying
+    // camera is detached.
+    ExternalCameraDevice(const std::string& cameraId, const ExternalCameraConfig& cfg);
+    virtual ~ExternalCameraDevice();
+
+    virtual sp<V3_2::ICameraDevice> getInterface() override {
+        return new TrampolineDeviceInterface_3_5(this);
+    }
+
+    Return<void> getPhysicalCameraCharacteristics(const hidl_string& physicalCameraId,
+            V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb);
+
+    Return<void> isStreamCombinationSupported(
+            const V3_4::StreamConfiguration& streams,
+            V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb);
+
+protected:
+    virtual sp<V3_4::implementation::ExternalCameraDeviceSession> createSession(
+            const sp<V3_2::ICameraDeviceCallback>&,
+            const ExternalCameraConfig& cfg,
+            const std::vector<SupportedV4L2Format>& sortedFormats,
+            const CroppingType& croppingType,
+            const common::V1_0::helper::CameraMetadata& chars,
+            const std::string& cameraId,
+            unique_fd v4l2Fd) override;
+
+    virtual status_t initDefaultCharsKeys(
+            ::android::hardware::camera::common::V1_0::helper::CameraMetadata*) override;
+
+    const std::vector<int32_t> EXTRA_CHARACTERISTICS_KEYS_3_5 = {
+        ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION
+    };
+
+private:
+    struct TrampolineDeviceInterface_3_5 : public ICameraDevice {
+        TrampolineDeviceInterface_3_5(sp<ExternalCameraDevice> parent) :
+            mParent(parent) {}
+
+        virtual Return<void> getResourceCost(V3_2::ICameraDevice::getResourceCost_cb _hidl_cb)
+                override {
+            return mParent->getResourceCost(_hidl_cb);
+        }
+
+        virtual Return<void> getCameraCharacteristics(
+                V3_2::ICameraDevice::getCameraCharacteristics_cb _hidl_cb) override {
+            return mParent->getCameraCharacteristics(_hidl_cb);
+        }
+
+        virtual Return<Status> setTorchMode(TorchMode mode) override {
+            return mParent->setTorchMode(mode);
+        }
+
+        virtual Return<void> open(const sp<V3_2::ICameraDeviceCallback>& callback,
+                V3_2::ICameraDevice::open_cb _hidl_cb) override {
+            return mParent->open(callback, _hidl_cb);
+        }
+
+        virtual Return<void> dumpState(const hidl_handle& fd) override {
+            return mParent->dumpState(fd);
+        }
+
+        virtual Return<void> getPhysicalCameraCharacteristics(const hidl_string& physicalCameraId,
+                V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb) override {
+            return mParent->getPhysicalCameraCharacteristics(physicalCameraId, _hidl_cb);
+        }
+
+        virtual Return<void> isStreamCombinationSupported(
+                const V3_4::StreamConfiguration& streams,
+                V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb) override {
+            return mParent->isStreamCombinationSupported(streams, _hidl_cb);
+        }
+
+    private:
+        sp<ExternalCameraDevice> mParent;
+    };
+};
+
+}  // namespace implementation
+}  // namespace V3_5
+}  // namespace device
+}  // namespace camera
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_CAMERA_DEVICE_V3_5_EXTCAMERADEVICE_H
diff --git a/camera/metadata/3.2/types.hal b/camera/metadata/3.2/types.hal
index 67b4e44..cef0397 100644
--- a/camera/metadata/3.2/types.hal
+++ b/camera/metadata/3.2/types.hal
@@ -1396,7 +1396,8 @@
      *
      * <p>The arrangement of color filters on sensor;
      * represents the colors in the top-left 2x2 section of
-     * the sensor, in reading order.</p>
+     * the sensor, in reading order, for a Bayer camera, or the
+     * light spectrum it captures for MONOCHROME camera.</p>
      */
     ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT,
 
diff --git a/camera/metadata/3.4/types.hal b/camera/metadata/3.4/types.hal
index 4eb6929..61a399e 100644
--- a/camera/metadata/3.4/types.hal
+++ b/camera/metadata/3.4/types.hal
@@ -113,6 +113,15 @@
                                                                  = 0x18,
 };
 
+/** android.sensor.info.colorFilterArrangement enumeration values added since v3.2
+ * @see ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT
+ */
+enum CameraMetadataEnumAndroidSensorInfoColorFilterArrangement :
+        @3.2::CameraMetadataEnumAndroidSensorInfoColorFilterArrangement {
+    ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_MONO,
+    ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_NIR,
+};
+
 /** android.info.supportedBufferManagementVersion enumeration values
  * @see ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION
  */
diff --git a/camera/provider/2.4/default/Android.bp b/camera/provider/2.4/default/Android.bp
index de02d78..167954c 100644
--- a/camera/provider/2.4/default/Android.bp
+++ b/camera/provider/2.4/default/Android.bp
@@ -21,6 +21,7 @@
         "camera.device@3.4-impl",
         "camera.device@3.5-impl",
         "camera.device@3.4-external-impl",
+        "camera.device@3.5-external-impl",
         "android.hardware.camera.provider@2.4",
         "android.hardware.camera.common@1.0",
         "android.hardware.graphics.mapper@2.0",
@@ -34,7 +35,8 @@
     header_libs: [
         "camera.device@3.4-impl_headers",
         "camera.device@3.5-impl_headers",
-        "camera.device@3.4-external-impl_headers"
+        "camera.device@3.4-external-impl_headers",
+        "camera.device@3.5-external-impl_headers"
     ],
     static_libs: [
         "android.hardware.camera.common@1.0-helper",
@@ -107,6 +109,8 @@
         "android.hardware.camera.device@1.0",
         "android.hardware.camera.device@3.2",
         "android.hardware.camera.device@3.3",
+        "android.hardware.camera.device@3.4",
+        "android.hardware.camera.device@3.5",
         "android.hardware.camera.provider@2.4",
         "android.hardware.camera.common@1.0",
     ],
diff --git a/camera/provider/2.4/default/ExternalCameraProvider.cpp b/camera/provider/2.4/default/ExternalCameraProvider.cpp
index 1cec0e5..604df5c 100644
--- a/camera/provider/2.4/default/ExternalCameraProvider.cpp
+++ b/camera/provider/2.4/default/ExternalCameraProvider.cpp
@@ -24,6 +24,8 @@
 #include <linux/videodev2.h>
 #include "ExternalCameraProvider.h"
 #include "ExternalCameraDevice_3_4.h"
+#include "ExternalCameraDevice_3_5.h"
+#include <cutils/properties.h>
 
 namespace android {
 namespace hardware {
@@ -62,6 +64,21 @@
         mCfg(ExternalCameraConfig::loadFromCfg()),
         mHotPlugThread(this) {
     mHotPlugThread.run("ExtCamHotPlug", PRIORITY_BACKGROUND);
+
+    mPreferredHal3MinorVersion =
+        property_get_int32("ro.vendor.camera.external.hal3TrebleMinorVersion", 4);
+    ALOGV("Preferred HAL 3 minor version is %d", mPreferredHal3MinorVersion);
+    switch(mPreferredHal3MinorVersion) {
+        case 4:
+        case 5:
+            // OK
+            break;
+        default:
+            ALOGW("Unknown minor camera device HAL version %d in property "
+                    "'camera.external.hal3TrebleMinorVersion', defaulting to 4",
+                    mPreferredHal3MinorVersion);
+            mPreferredHal3MinorVersion = 4;
+    }
 }
 
 ExternalCameraProvider::~ExternalCameraProvider() {
@@ -136,20 +153,43 @@
         return Void();
     }
 
-    ALOGV("Constructing v3.4 external camera device");
-    sp<device::V3_2::ICameraDevice> device;
-    sp<device::V3_4::implementation::ExternalCameraDevice> deviceImpl =
-            new device::V3_4::implementation::ExternalCameraDevice(
+    sp<device::V3_4::implementation::ExternalCameraDevice> deviceImpl;
+    switch (mPreferredHal3MinorVersion) {
+        case 4: {
+            ALOGV("Constructing v3.4 external camera device");
+            deviceImpl = new device::V3_4::implementation::ExternalCameraDevice(
                     cameraId, mCfg);
+            break;
+        }
+        case 5: {
+            ALOGV("Constructing v3.5 external camera device");
+            deviceImpl = new device::V3_5::implementation::ExternalCameraDevice(
+                    cameraId, mCfg);
+            break;
+        }
+        default:
+            ALOGE("%s: Unknown HAL minor version %d!", __FUNCTION__, mPreferredHal3MinorVersion);
+            _hidl_cb(Status::INTERNAL_ERROR, nullptr);
+            return Void();
+    }
+
     if (deviceImpl == nullptr || deviceImpl->isInitFailed()) {
         ALOGE("%s: camera device %s init failed!", __FUNCTION__, cameraId.c_str());
-        device = nullptr;
         _hidl_cb(Status::INTERNAL_ERROR, nullptr);
         return Void();
     }
-    device = deviceImpl;
 
-    _hidl_cb (Status::OK, device);
+    IF_ALOGV() {
+        deviceImpl->getInterface()->interfaceChain([](
+            ::android::hardware::hidl_vec<::android::hardware::hidl_string> interfaceChain) {
+                ALOGV("Device interface chain:");
+                for (auto iface : interfaceChain) {
+                    ALOGV("  %s", iface.c_str());
+                }
+            });
+    }
+
+    _hidl_cb (Status::OK, deviceImpl->getInterface());
 
     return Void();
 }
@@ -157,7 +197,12 @@
 void ExternalCameraProvider::addExternalCamera(const char* devName) {
     ALOGI("ExtCam: adding %s to External Camera HAL!", devName);
     Mutex::Autolock _l(mLock);
-    std::string deviceName = std::string("device@3.4/external/") + devName;
+    std::string deviceName;
+    if (mPreferredHal3MinorVersion == 5) {
+        deviceName = std::string("device@3.5/external/") + devName;
+    } else {
+        deviceName = std::string("device@3.4/external/") + devName;
+    }
     mCameraStatusMap[deviceName] = CameraDeviceStatus::PRESENT;
     if (mCallbacks != nullptr) {
         mCallbacks->cameraDeviceStatusChange(deviceName, CameraDeviceStatus::PRESENT);
@@ -199,7 +244,12 @@
 
 void ExternalCameraProvider::deviceRemoved(const char* devName) {
     Mutex::Autolock _l(mLock);
-    std::string deviceName = std::string("device@3.4/external/") + devName;
+    std::string deviceName;
+    if (mPreferredHal3MinorVersion == 5) {
+        deviceName = std::string("device@3.5/external/") + devName;
+    } else {
+        deviceName = std::string("device@3.4/external/") + devName;
+    }
     if (mCameraStatusMap.find(deviceName) != mCameraStatusMap.end()) {
         mCameraStatusMap.erase(deviceName);
         if (mCallbacks != nullptr) {
diff --git a/camera/provider/2.4/default/ExternalCameraProvider.h b/camera/provider/2.4/default/ExternalCameraProvider.h
index c83cc70..a69cf8b 100644
--- a/camera/provider/2.4/default/ExternalCameraProvider.h
+++ b/camera/provider/2.4/default/ExternalCameraProvider.h
@@ -95,6 +95,7 @@
     std::unordered_map<std::string, CameraDeviceStatus> mCameraStatusMap; // camera id -> status
     const ExternalCameraConfig mCfg;
     HotplugThread mHotPlugThread;
+    int mPreferredHal3MinorVersion;
 };
 
 
diff --git a/camera/provider/2.4/vts/functional/Android.bp b/camera/provider/2.4/vts/functional/Android.bp
index eb8d43e..f8f058e 100644
--- a/camera/provider/2.4/vts/functional/Android.bp
+++ b/camera/provider/2.4/vts/functional/Android.bp
@@ -38,6 +38,7 @@
         "android.hardware.camera.device@3.3",
         "android.hardware.camera.device@3.4",
         "android.hardware.camera.device@3.5",
+	"android.hardware.camera.metadata@3.4",
         "android.hardware.camera.provider@2.4",
         "android.hardware.graphics.allocator@2.0",
         "android.hardware.graphics.common@1.0",
@@ -46,4 +47,5 @@
         "libgrallocusage",
         "libhidlmemory",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index 837905c..e376551 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -31,8 +31,11 @@
 #include <android/hardware/camera/device/3.5/ICameraDevice.h>
 #include <android/hardware/camera/device/3.3/ICameraDeviceSession.h>
 #include <android/hardware/camera/device/3.4/ICameraDeviceSession.h>
+#include <android/hardware/camera/device/3.5/ICameraDeviceSession.h>
 #include <android/hardware/camera/device/3.4/ICameraDeviceCallback.h>
+#include <android/hardware/camera/device/3.5/ICameraDeviceCallback.h>
 #include <android/hardware/camera/provider/2.4/ICameraProvider.h>
+#include <android/hardware/camera/metadata/3.4/types.h>
 #include <android/hidl/manager/1.0/IServiceManager.h>
 #include <binder/MemoryHeapBase.h>
 #include <CameraMetadata.h>
@@ -110,6 +113,7 @@
 using ::android::hardware::camera::device::V1_0::ICameraDevicePreviewCallback;
 using ::android::hardware::camera::device::V1_0::FrameCallbackFlag;
 using ::android::hardware::camera::device::V1_0::HandleTimestampMessage;
+using ::android::hardware::camera::metadata::V3_4::CameraMetadataEnumAndroidSensorInfoColorFilterArrangement;
 using ::android::hardware::MessageQueue;
 using ::android::hardware::kSynchronizedReadWrite;
 using ::android::hidl::allocator::V1_0::IAllocator;
@@ -130,6 +134,7 @@
 const int64_t kEmptyFlushTimeoutMSec = 200;
 const char kDumpOutput[] = "/dev/null";
 const uint32_t kBurstFrameCount = 10;
+const int64_t kBufferReturnTimeoutSec = 1;
 
 struct AvailableStream {
     int32_t width;
@@ -142,6 +147,11 @@
     int32_t outputFormat;
 };
 
+enum ReprocessType {
+    PRIV_REPROCESS,
+    YUV_REPROCESS,
+};
+
 namespace {
     // "device@<version>/legacy/<id>"
     const char *kDeviceNameRE = "device@([0-9]+\\.[0-9]+)/%s/(.+)";
@@ -536,7 +546,7 @@
 
  hidl_vec<hidl_string> getCameraDeviceNames(sp<ICameraProvider> provider);
 
- struct EmptyDeviceCb : public V3_4::ICameraDeviceCallback {
+    struct EmptyDeviceCb : public V3_5::ICameraDeviceCallback {
      virtual Return<void> processCaptureResult(
          const hidl_vec<CaptureResult>& /*results*/) override {
          ALOGI("processCaptureResult callback");
@@ -556,19 +566,63 @@
          ADD_FAILURE();  // Empty callback should not reach here
          return Void();
      }
+
+     virtual Return<void> requestStreamBuffers(
+             const hidl_vec<V3_5::BufferRequest>&,
+             requestStreamBuffers_cb _hidl_cb) override {
+         ALOGI("requestStreamBuffers callback");
+         // HAL might want to request buffer after configureStreams, but tests with EmptyDeviceCb
+         // doesn't actually need to send capture requests, so just return an error.
+         hidl_vec<V3_5::StreamBufferRet> emptyBufRets;
+         _hidl_cb(V3_5::BufferRequestStatus::FAILED_UNKNOWN, emptyBufRets);
+         return Void();
+     }
+
+     virtual Return<void> returnStreamBuffers(const hidl_vec<StreamBuffer>&) override {
+         ALOGI("returnStreamBuffers");
+         ADD_FAILURE();  // Empty callback should not reach here
+         return Void();
+     }
+
     };
 
-    struct DeviceCb : public V3_4::ICameraDeviceCallback {
-        DeviceCb(CameraHidlTest *parent) : mParent(parent) {}
+    struct DeviceCb : public V3_5::ICameraDeviceCallback {
+        DeviceCb(CameraHidlTest *parent, bool checkMonochromeResult) : mParent(parent),
+                mCheckMonochromeResult(checkMonochromeResult) {}
+
         Return<void> processCaptureResult_3_4(
                 const hidl_vec<V3_4::CaptureResult>& results) override;
         Return<void> processCaptureResult(const hidl_vec<CaptureResult>& results) override;
         Return<void> notify(const hidl_vec<NotifyMsg>& msgs) override;
 
+        Return<void> requestStreamBuffers(
+                const hidl_vec<V3_5::BufferRequest>& bufReqs,
+                requestStreamBuffers_cb _hidl_cb) override;
+
+        Return<void> returnStreamBuffers(const hidl_vec<StreamBuffer>& buffers) override;
+
+        void setCurrentStreamConfig(const hidl_vec<V3_2::Stream>& streams,
+                const hidl_vec<V3_2::HalStream>& halStreams);
+
+        void waitForBuffersReturned();
+
      private:
         bool processCaptureResultLocked(const CaptureResult& results);
 
-        CameraHidlTest *mParent;               // Parent object
+        CameraHidlTest *mParent; // Parent object
+        bool mCheckMonochromeResult;
+        bool hasOutstandingBuffersLocked();
+
+        /* members for requestStreamBuffers() and returnStreamBuffers()*/
+        std::mutex mLock; // protecting members below
+        bool                      mUseHalBufManager = false;
+        hidl_vec<V3_2::Stream>    mStreams;
+        hidl_vec<V3_2::HalStream> mHalStreams;
+        uint64_t mNextBufferId = 1;
+        using OutstandingBuffers = std::unordered_map<uint64_t, hidl_handle>;
+        // size == mStreams.size(). Tracking each streams outstanding buffers
+        std::vector<OutstandingBuffers> mOutstandingBufferIds;
+        std::condition_variable mFlushedCondition;
     };
 
     struct TorchProviderCb : public ICameraProviderCallback {
@@ -649,24 +703,33 @@
     void openEmptyDeviceSession(const std::string &name,
             sp<ICameraProvider> provider,
             sp<ICameraDeviceSession> *session /*out*/,
-            camera_metadata_t **staticMeta /*out*/);
+            camera_metadata_t **staticMeta /*out*/,
+            ::android::sp<ICameraDevice> *device = nullptr/*out*/);
     void castSession(const sp<ICameraDeviceSession> &session, int32_t deviceVersion,
             sp<device::V3_3::ICameraDeviceSession> *session3_3 /*out*/,
-            sp<device::V3_4::ICameraDeviceSession> *session3_4 /*out*/);
+            sp<device::V3_4::ICameraDeviceSession> *session3_4 /*out*/,
+            sp<device::V3_5::ICameraDeviceSession> *session3_5 /*out*/);
+    void castDevice(const sp<device::V3_2::ICameraDevice> &device, int32_t deviceVersion,
+            sp<device::V3_5::ICameraDevice> *device3_5/*out*/);
     void createStreamConfiguration(const ::android::hardware::hidl_vec<V3_2::Stream>& streams3_2,
             StreamConfigurationMode configMode,
             ::android::hardware::camera::device::V3_2::StreamConfiguration *config3_2,
-            ::android::hardware::camera::device::V3_4::StreamConfiguration *config3_4);
+            ::android::hardware::camera::device::V3_4::StreamConfiguration *config3_4,
+            ::android::hardware::camera::device::V3_5::StreamConfiguration *config3_5);
 
     void configurePreviewStreams3_4(const std::string &name, int32_t deviceVersion,
             sp<ICameraProvider> provider,
             const AvailableStream *previewThreshold,
             const std::unordered_set<std::string>& physicalIds,
             sp<device::V3_4::ICameraDeviceSession> *session3_4 /*out*/,
+            sp<device::V3_5::ICameraDeviceSession> *session3_5 /*out*/,
             V3_2::Stream* previewStream /*out*/,
             device::V3_4::HalStreamConfiguration *halStreamConfig /*out*/,
             bool *supportsPartialResults /*out*/,
-            uint32_t *partialResultCount /*out*/);
+            uint32_t *partialResultCount /*out*/,
+            bool *useHalBufManager /*out*/,
+            sp<DeviceCb> *cb /*out*/,
+            uint32_t streamConfigCounter = 0);
     void configurePreviewStream(const std::string &name, int32_t deviceVersion,
             sp<ICameraProvider> provider,
             const AvailableStream *previewThreshold,
@@ -674,7 +737,10 @@
             V3_2::Stream *previewStream /*out*/,
             HalStreamConfiguration *halStreamConfig /*out*/,
             bool *supportsPartialResults /*out*/,
-            uint32_t *partialResultCount /*out*/);
+            uint32_t *partialResultCount /*out*/,
+            bool *useHalBufManager /*out*/,
+            sp<DeviceCb> *cb /*out*/,
+            uint32_t streamConfigCounter = 0);
 
     void verifyLogicalCameraMetadata(const std::string& cameraName,
             const ::android::sp<::android::hardware::camera::device::V3_2::ICameraDevice>& device,
@@ -682,6 +748,20 @@
             const hidl_vec<hidl_string>& deviceNames);
     void verifyCameraCharacteristics(Status status, const CameraMetadata& chars);
     void verifyRecommendedConfigs(const CameraMetadata& metadata);
+    void verifyMonochromeCharacteristics(const CameraMetadata& chars, int deviceVersion);
+    void verifyMonochromeCameraResult(
+            const ::android::hardware::camera::common::V1_0::helper::CameraMetadata& metadata);
+    void verifyStreamCombination(sp<device::V3_5::ICameraDevice> cameraDevice3_5,
+            const ::android::hardware::camera::device::V3_4::StreamConfiguration &config3_4,
+            bool expectedStatus);
+
+    void verifyBuffersReturned(sp<device::V3_2::ICameraDeviceSession> session,
+            int deviceVerison, int32_t streamId, sp<DeviceCb> cb,
+            uint32_t streamConfigCounter = 0);
+
+    void verifyBuffersReturned(sp<device::V3_4::ICameraDeviceSession> session,
+            hidl_vec<int32_t> streamIds, sp<DeviceCb> cb,
+            uint32_t streamConfigCounter = 0);
 
     static Status getAvailableOutputStreams(camera_metadata_t *staticMeta,
             std::vector<AvailableStream> &outputStreams,
@@ -700,6 +780,7 @@
     static Status pickConstrainedModeSize(camera_metadata_t *staticMeta,
             AvailableStream &hfrStream);
     static Status isZSLModeAvailable(const camera_metadata_t *staticMeta);
+    static Status isZSLModeAvailable(const camera_metadata_t *staticMeta, ReprocessType reprocType);
     static Status getZSLInputOutputMap(camera_metadata_t *staticMeta,
             std::vector<AvailableZSLInputOutput> &inputOutputMap);
     static Status findLargestSize(
@@ -707,6 +788,7 @@
             int32_t format, AvailableStream &result);
     static Status isAutoFocusModeAvailable(
             CameraParameters &cameraParams, const char *mode) ;
+    static Status isMonochromeCamera(const camera_metadata_t *staticMeta);
 
 protected:
 
@@ -1050,6 +1132,11 @@
         }
         request->haveResultMetadata = true;
         request->collectedResult.sort();
+
+        // Verify final result metadata
+        if (mCheckMonochromeResult) {
+            mParent->verifyMonochromeCameraResult(request->collectedResult);
+        }
     }
 
     uint32_t numBuffersReturned = results.outputBuffers.size();
@@ -1075,9 +1162,51 @@
     if (request->shutterTimestamp != 0) {
         notify = true;
     }
+
+    if (mUseHalBufManager) {
+        returnStreamBuffers(results.outputBuffers);
+    }
     return notify;
 }
 
+void CameraHidlTest::DeviceCb::setCurrentStreamConfig(
+        const hidl_vec<V3_2::Stream>& streams, const hidl_vec<V3_2::HalStream>& halStreams) {
+    ASSERT_EQ(streams.size(), halStreams.size());
+    ASSERT_NE(streams.size(), 0);
+    for (size_t i = 0; i < streams.size(); i++) {
+        ASSERT_EQ(streams[i].id, halStreams[i].id);
+    }
+    std::lock_guard<std::mutex> l(mLock);
+    mUseHalBufManager = true;
+    mStreams = streams;
+    mHalStreams = halStreams;
+    mOutstandingBufferIds.clear();
+    for (size_t i = 0; i < streams.size(); i++) {
+        mOutstandingBufferIds.emplace_back();
+    }
+}
+
+bool CameraHidlTest::DeviceCb::hasOutstandingBuffersLocked() {
+    if (!mUseHalBufManager) {
+        return false;
+    }
+    for (const auto& outstandingBuffers : mOutstandingBufferIds) {
+        if (!outstandingBuffers.empty()) {
+            return true;
+        }
+    }
+    return false;
+}
+
+void CameraHidlTest::DeviceCb::waitForBuffersReturned() {
+    std::unique_lock<std::mutex> lk(mLock);
+    if (hasOutstandingBuffersLocked()) {
+        auto timeout = std::chrono::seconds(kBufferReturnTimeoutSec);
+        auto st = mFlushedCondition.wait_for(lk, timeout);
+        ASSERT_NE(std::cv_status::timeout, st);
+    }
+}
+
 Return<void> CameraHidlTest::DeviceCb::notify(
         const hidl_vec<NotifyMsg>& messages) {
     std::lock_guard<std::mutex> l(mParent->mLock);
@@ -1120,6 +1249,124 @@
     return Void();
 }
 
+Return<void> CameraHidlTest::DeviceCb::requestStreamBuffers(
+        const hidl_vec<V3_5::BufferRequest>& bufReqs,
+        requestStreamBuffers_cb _hidl_cb) {
+    using V3_5::BufferRequestStatus;
+    using V3_5::StreamBufferRet;
+    using V3_5::StreamBufferRequestError;
+    hidl_vec<StreamBufferRet> bufRets;
+    std::unique_lock<std::mutex> l(mLock);
+
+    if (!mUseHalBufManager) {
+        ALOGE("%s: Camera does not support HAL buffer management", __FUNCTION__);
+        ADD_FAILURE();
+        _hidl_cb(BufferRequestStatus::FAILED_ILLEGAL_ARGUMENTS, bufRets);
+        return Void();
+    }
+
+    if (bufReqs.size() > mStreams.size()) {
+        ALOGE("%s: illegal buffer request: too many requests!", __FUNCTION__);
+        ADD_FAILURE();
+        _hidl_cb(BufferRequestStatus::FAILED_ILLEGAL_ARGUMENTS, bufRets);
+        return Void();
+    }
+
+    std::vector<int32_t> indexes(bufReqs.size());
+    for (size_t i = 0; i < bufReqs.size(); i++) {
+        bool found = false;
+        for (size_t idx = 0; idx < mStreams.size(); idx++) {
+            if (bufReqs[i].streamId == mStreams[idx].id) {
+                found = true;
+                indexes[i] = idx;
+                break;
+            }
+        }
+        if (!found) {
+            ALOGE("%s: illegal buffer request: unknown streamId %d!",
+                    __FUNCTION__, bufReqs[i].streamId);
+            ADD_FAILURE();
+            _hidl_cb(BufferRequestStatus::FAILED_ILLEGAL_ARGUMENTS, bufRets);
+            return Void();
+        }
+    }
+
+    bool allStreamOk = true;
+    bool atLeastOneStreamOk = false;
+    bufRets.resize(bufReqs.size());
+    for (size_t i = 0; i < bufReqs.size(); i++) {
+        int32_t idx = indexes[i];
+        const auto& stream = mStreams[idx];
+        const auto& halStream = mHalStreams[idx];
+        const V3_5::BufferRequest& bufReq = bufReqs[i];
+        if (mOutstandingBufferIds[idx].size() + bufReq.numBuffersRequested > halStream.maxBuffers) {
+            bufRets[i].streamId = stream.id;
+            bufRets[i].val.error(StreamBufferRequestError::MAX_BUFFER_EXCEEDED);
+            allStreamOk = false;
+            continue;
+        }
+
+        hidl_vec<StreamBuffer> tmpRetBuffers(bufReq.numBuffersRequested);
+        for (size_t i = 0; i < bufReq.numBuffersRequested; i++) {
+            hidl_handle buffer_handle;
+            mParent->allocateGraphicBuffer(stream.width, stream.height,
+                    android_convertGralloc1To0Usage(
+                            halStream.producerUsage, halStream.consumerUsage),
+                    halStream.overrideFormat, &buffer_handle);
+
+            tmpRetBuffers[i] = {stream.id, mNextBufferId, buffer_handle, BufferStatus::OK,
+                                nullptr, nullptr};
+            mOutstandingBufferIds[idx].insert(std::make_pair(mNextBufferId++, buffer_handle));
+        }
+        atLeastOneStreamOk = true;
+        bufRets[0].val.buffers(std::move(tmpRetBuffers));
+    }
+
+    if (allStreamOk) {
+        _hidl_cb(BufferRequestStatus::OK, bufRets);
+    } else if (atLeastOneStreamOk) {
+        _hidl_cb(BufferRequestStatus::FAILED_PARTIAL, bufRets);
+    } else {
+        _hidl_cb(BufferRequestStatus::FAILED_UNKNOWN, bufRets);
+    }
+
+    if (!hasOutstandingBuffersLocked()) {
+        l.unlock();
+        mFlushedCondition.notify_one();
+    }
+    return Void();
+}
+
+Return<void> CameraHidlTest::DeviceCb::returnStreamBuffers(
+        const hidl_vec<StreamBuffer>& buffers) {
+    if (!mUseHalBufManager) {
+        ALOGE("%s: Camera does not support HAL buffer management", __FUNCTION__);
+        ADD_FAILURE();
+    }
+
+    std::lock_guard<std::mutex> l(mLock);
+    for (const auto& buf : buffers) {
+        bool found = false;
+        for (size_t idx = 0; idx < mOutstandingBufferIds.size(); idx++) {
+            if (mStreams[idx].id == buf.streamId &&
+                    mOutstandingBufferIds[idx].count(buf.bufferId) == 1) {
+                mOutstandingBufferIds[idx].erase(buf.bufferId);
+                // TODO: check do we need to close/delete native handle or assume we have enough
+                // memory to run till the test finish? since we do not capture much requests (and
+                // most of time one buffer is sufficient)
+                found = true;
+                break;
+            }
+        }
+        if (found) {
+            continue;
+        }
+        ALOGE("%s: unknown buffer ID %" PRIu64, __FUNCTION__, buf.bufferId);
+        ADD_FAILURE();
+    }
+    return Void();
+}
+
 hidl_vec<hidl_string> CameraHidlTest::getCameraDeviceNames(sp<ICameraProvider> provider) {
     std::vector<std::string> cameraDeviceNames;
     Return<void> ret;
@@ -2080,6 +2327,7 @@
 
                 ret = device3_x->getCameraCharacteristics([&](auto status, const auto& chars) {
                     verifyCameraCharacteristics(status, chars);
+                    verifyMonochromeCharacteristics(chars, deviceVersion);
                     verifyRecommendedConfigs(chars);
                     verifyLogicalCameraMetadata(name, device3_x, chars, deviceVersion,
                             cameraDeviceNames);
@@ -2359,14 +2607,18 @@
                 // cast the 3.3/3.4 interface, and that lower versions can't be cast to it.
                 sp<device::V3_3::ICameraDeviceSession> sessionV3_3;
                 sp<device::V3_4::ICameraDeviceSession> sessionV3_4;
-                castSession(session, deviceVersion, &sessionV3_3, &sessionV3_4);
-                if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_4 ||
-                        deviceVersion == CAMERA_DEVICE_API_VERSION_3_5) {
+                sp<device::V3_5::ICameraDeviceSession> sessionV3_5;
+                castSession(session, deviceVersion, &sessionV3_3, &sessionV3_4, &sessionV3_5);
+                if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_5) {
+                    ASSERT_TRUE(sessionV3_5.get() != nullptr);
+                } else if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_4) {
                     ASSERT_TRUE(sessionV3_4.get() != nullptr);
                 } else if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_3) {
                     ASSERT_TRUE(sessionV3_3.get() != nullptr);
-                } else {
+                } else { //V3_2
                     ASSERT_TRUE(sessionV3_3.get() == nullptr);
+                    ASSERT_TRUE(sessionV3_4.get() == nullptr);
+                    ASSERT_TRUE(sessionV3_5.get() == nullptr);
                 }
                 native_handle_t* raw_handle = native_handle_create(1, 0);
                 raw_handle->data[0] = open(kDumpOutput, O_RDWR);
@@ -2522,15 +2774,20 @@
         sp<ICameraDeviceSession> session;
         sp<device::V3_3::ICameraDeviceSession> session3_3;
         sp<device::V3_4::ICameraDeviceSession> session3_4;
+        sp<device::V3_5::ICameraDeviceSession> session3_5;
+        sp<device::V3_2::ICameraDevice> cameraDevice;
+        sp<device::V3_5::ICameraDevice> cameraDevice3_5;
         openEmptyDeviceSession(name, mProvider,
-                &session /*out*/, &staticMeta /*out*/);
-        castSession(session, deviceVersion, &session3_3, &session3_4);
+                &session /*out*/, &staticMeta /*out*/, &cameraDevice /*out*/);
+        castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5);
+        castDevice(cameraDevice, deviceVersion, &cameraDevice3_5);
 
         outputStreams.clear();
         ASSERT_EQ(Status::OK, getAvailableOutputStreams(staticMeta, outputStreams));
         ASSERT_NE(0u, outputStreams.size());
 
         int32_t streamId = 0;
+        uint32_t streamConfigCounter = 0;
         for (auto& it : outputStreams) {
             V3_2::Stream stream3_2;
             bool isJpeg = static_cast<PixelFormat>(it.format) == PixelFormat::BLOB;
@@ -2543,11 +2800,22 @@
                              (isJpeg) ? static_cast<V3_2::DataspaceFlags>(Dataspace::V0_JFIF) : 0,
                              StreamRotation::ROTATION_0};
             ::android::hardware::hidl_vec<V3_2::Stream> streams3_2 = {stream3_2};
+            ::android::hardware::camera::device::V3_5::StreamConfiguration config3_5;
             ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4;
             ::android::hardware::camera::device::V3_2::StreamConfiguration config3_2;
             createStreamConfiguration(streams3_2, StreamConfigurationMode::NORMAL_MODE,
-                                      &config3_2, &config3_4);
-            if (session3_4 != nullptr) {
+                                      &config3_2, &config3_4, &config3_5);
+            if (session3_5 != nullptr) {
+                verifyStreamCombination(cameraDevice3_5, config3_4,
+                        /*expectedStatus*/ true);
+                config3_5.streamConfigCounter = streamConfigCounter++;
+                ret = session3_5->configureStreams_3_5(config3_5,
+                        [streamId](Status s, device::V3_4::HalStreamConfiguration halConfig) {
+                            ASSERT_EQ(Status::OK, s);
+                            ASSERT_EQ(1u, halConfig.streams.size());
+                            ASSERT_EQ(halConfig.streams[0].v3_3.v3_2.id, streamId);
+                        });
+            } else if (session3_4 != nullptr) {
                 ret = session3_4->configureStreams_3_4(config3_4,
                         [streamId](Status s, device::V3_4::HalStreamConfiguration halConfig) {
                             ASSERT_EQ(Status::OK, s);
@@ -2599,8 +2867,13 @@
         sp<ICameraDeviceSession> session;
         sp<device::V3_3::ICameraDeviceSession> session3_3;
         sp<device::V3_4::ICameraDeviceSession> session3_4;
-        openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/);
-        castSession(session, deviceVersion, &session3_3, &session3_4);
+        sp<device::V3_5::ICameraDeviceSession> session3_5;
+        sp<device::V3_2::ICameraDevice> cameraDevice;
+        sp<device::V3_5::ICameraDevice> cameraDevice3_5;
+        openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/,
+                &cameraDevice /*out*/);
+        castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5);
+        castDevice(cameraDevice, deviceVersion, &cameraDevice3_5);
 
         outputStreams.clear();
         ASSERT_EQ(Status::OK, getAvailableOutputStreams(staticMeta, outputStreams));
@@ -2615,29 +2888,39 @@
                          GRALLOC1_CONSUMER_USAGE_HWCOMPOSER,
                          0,
                          StreamRotation::ROTATION_0};
+        uint32_t streamConfigCounter = 0;
         ::android::hardware::hidl_vec<V3_2::Stream> streams = {stream3_2};
+        ::android::hardware::camera::device::V3_5::StreamConfiguration config3_5;
         ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4;
         ::android::hardware::camera::device::V3_2::StreamConfiguration config3_2;
         createStreamConfiguration(streams, StreamConfigurationMode::NORMAL_MODE,
-                                  &config3_2, &config3_4);
-        if(session3_4 != nullptr) {
-            ret = session3_4->configureStreams_3_4(config3_4,
-                [](Status s, device::V3_4::HalStreamConfiguration) {
-                    ASSERT_TRUE((Status::ILLEGAL_ARGUMENT == s) ||
+                                  &config3_2, &config3_4, &config3_5);
+        if (session3_5 != nullptr) {
+            verifyStreamCombination(cameraDevice3_5, config3_4, /*expectedStatus*/ false);
+            config3_5.streamConfigCounter = streamConfigCounter++;
+            ret = session3_5->configureStreams_3_5(config3_5,
+                    [](Status s, device::V3_4::HalStreamConfiguration) {
+                        ASSERT_TRUE((Status::ILLEGAL_ARGUMENT == s) ||
                             (Status::INTERNAL_ERROR == s));
-                });
+                    });
+        } else if (session3_4 != nullptr) {
+            ret = session3_4->configureStreams_3_4(config3_4,
+                    [](Status s, device::V3_4::HalStreamConfiguration) {
+                        ASSERT_TRUE((Status::ILLEGAL_ARGUMENT == s) ||
+                                (Status::INTERNAL_ERROR == s));
+                    });
         } else if(session3_3 != nullptr) {
             ret = session3_3->configureStreams_3_3(config3_2,
-                [](Status s, device::V3_3::HalStreamConfiguration) {
-                    ASSERT_TRUE((Status::ILLEGAL_ARGUMENT == s) ||
-                            (Status::INTERNAL_ERROR == s));
-                });
+                    [](Status s, device::V3_3::HalStreamConfiguration) {
+                        ASSERT_TRUE((Status::ILLEGAL_ARGUMENT == s) ||
+                                (Status::INTERNAL_ERROR == s));
+                    });
         } else {
             ret = session->configureStreams(config3_2,
-                [](Status s, HalStreamConfiguration) {
-                    ASSERT_TRUE((Status::ILLEGAL_ARGUMENT == s) ||
-                            (Status::INTERNAL_ERROR == s));
-                });
+                    [](Status s, HalStreamConfiguration) {
+                        ASSERT_TRUE((Status::ILLEGAL_ARGUMENT == s) ||
+                                (Status::INTERNAL_ERROR == s));
+                    });
         }
         ASSERT_TRUE(ret.isOk());
 
@@ -2651,8 +2934,14 @@
                   StreamRotation::ROTATION_0};
         streams[0] = stream3_2;
         createStreamConfiguration(streams, StreamConfigurationMode::NORMAL_MODE,
-                &config3_2, &config3_4);
-        if(session3_4 != nullptr) {
+                &config3_2, &config3_4, &config3_5);
+        if (session3_5 != nullptr) {
+            config3_5.streamConfigCounter = streamConfigCounter++;
+            ret = session3_5->configureStreams_3_5(config3_5, [](Status s,
+                        device::V3_4::HalStreamConfiguration) {
+                    ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s);
+                });
+        } else if(session3_4 != nullptr) {
             ret = session3_4->configureStreams_3_4(config3_4, [](Status s,
                         device::V3_4::HalStreamConfiguration) {
                     ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s);
@@ -2681,8 +2970,14 @@
                       StreamRotation::ROTATION_0};
             streams[0] = stream3_2;
             createStreamConfiguration(streams, StreamConfigurationMode::NORMAL_MODE,
-                    &config3_2, &config3_4);
-            if(session3_4 != nullptr) {
+                    &config3_2, &config3_4, &config3_5);
+            if (session3_5 != nullptr) {
+                config3_5.streamConfigCounter = streamConfigCounter++;
+                ret = session3_5->configureStreams_3_5(config3_5,
+                        [](Status s, device::V3_4::HalStreamConfiguration) {
+                            ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s);
+                        });
+            } else if(session3_4 != nullptr) {
                 ret = session3_4->configureStreams_3_4(config3_4,
                         [](Status s, device::V3_4::HalStreamConfiguration) {
                             ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s);
@@ -2710,8 +3005,14 @@
                       static_cast<StreamRotation>(UINT32_MAX)};
             streams[0] = stream3_2;
             createStreamConfiguration(streams, StreamConfigurationMode::NORMAL_MODE,
-                    &config3_2, &config3_4);
-            if(session3_4 != nullptr) {
+                    &config3_2, &config3_4, &config3_5);
+            if (session3_5 != nullptr) {
+                config3_5.streamConfigCounter = streamConfigCounter++;
+                ret = session3_5->configureStreams_3_5(config3_5,
+                        [](Status s, device::V3_4::HalStreamConfiguration) {
+                            ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s);
+                        });
+            } else if(session3_4 != nullptr) {
                 ret = session3_4->configureStreams_3_4(config3_4,
                         [](Status s, device::V3_4::HalStreamConfiguration) {
                             ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s);
@@ -2758,8 +3059,13 @@
         sp<ICameraDeviceSession> session;
         sp<device::V3_3::ICameraDeviceSession> session3_3;
         sp<device::V3_4::ICameraDeviceSession> session3_4;
-        openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/);
-        castSession(session, deviceVersion, &session3_3, &session3_4);
+        sp<device::V3_5::ICameraDeviceSession> session3_5;
+        sp<device::V3_2::ICameraDevice> cameraDevice;
+        sp<device::V3_5::ICameraDevice> cameraDevice3_5;
+        openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/,
+                &cameraDevice /*out*/);
+        castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5);
+        castDevice(cameraDevice, deviceVersion, &cameraDevice3_5);
 
         Status rc = isZSLModeAvailable(staticMeta);
         if (Status::METHOD_NOT_SUPPORTED == rc) {
@@ -2777,13 +3083,35 @@
         ASSERT_EQ(Status::OK, getZSLInputOutputMap(staticMeta, inputOutputMap));
         ASSERT_NE(0u, inputOutputMap.size());
 
+        bool supportMonoY8 = false;
+        if (Status::OK == isMonochromeCamera(staticMeta)) {
+            for (auto& it : inputStreams) {
+                if (it.format == static_cast<uint32_t>(PixelFormat::Y8)) {
+                    supportMonoY8 = true;
+                    break;
+                }
+            }
+        }
+
         int32_t streamId = 0;
+        bool hasPrivToY8 = false, hasY8ToY8 = false, hasY8ToBlob = false;
+        uint32_t streamConfigCounter = 0;
         for (auto& inputIter : inputOutputMap) {
             AvailableStream input;
             ASSERT_EQ(Status::OK, findLargestSize(inputStreams, inputIter.inputFormat,
                     input));
             ASSERT_NE(0u, inputStreams.size());
 
+            if (inputIter.inputFormat == static_cast<uint32_t>(PixelFormat::IMPLEMENTATION_DEFINED)
+                    && inputIter.outputFormat == static_cast<uint32_t>(PixelFormat::Y8)) {
+                hasPrivToY8 = true;
+            } else if (inputIter.inputFormat == static_cast<uint32_t>(PixelFormat::Y8)) {
+                if (inputIter.outputFormat == static_cast<uint32_t>(PixelFormat::BLOB)) {
+                    hasY8ToBlob = true;
+                } else if (inputIter.outputFormat == static_cast<uint32_t>(PixelFormat::Y8)) {
+                    hasY8ToY8 = true;
+                }
+            }
             AvailableStream outputThreshold = {INT32_MAX, INT32_MAX,
                                                inputIter.outputFormat};
             std::vector<AvailableStream> outputStreams;
@@ -2818,11 +3146,21 @@
 
                 ::android::hardware::hidl_vec<V3_2::Stream> streams = {inputStream, zslStream,
                                                                  outputStream};
+                ::android::hardware::camera::device::V3_5::StreamConfiguration config3_5;
                 ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4;
                 ::android::hardware::camera::device::V3_2::StreamConfiguration config3_2;
                 createStreamConfiguration(streams, StreamConfigurationMode::NORMAL_MODE,
-                                          &config3_2, &config3_4);
-                if (session3_4 != nullptr) {
+                                          &config3_2, &config3_4, &config3_5);
+                if (session3_5 != nullptr) {
+                    verifyStreamCombination(cameraDevice3_5, config3_4,
+                            /*expectedStatus*/ true);
+                    config3_5.streamConfigCounter = streamConfigCounter++;
+                    ret = session3_5->configureStreams_3_5(config3_5,
+                            [](Status s, device::V3_4::HalStreamConfiguration halConfig) {
+                                ASSERT_EQ(Status::OK, s);
+                                ASSERT_EQ(3u, halConfig.streams.size());
+                            });
+                } else if (session3_4 != nullptr) {
                     ret = session3_4->configureStreams_3_4(config3_4,
                             [](Status s, device::V3_4::HalStreamConfiguration halConfig) {
                                 ASSERT_EQ(Status::OK, s);
@@ -2845,6 +3183,16 @@
             }
         }
 
+        if (supportMonoY8) {
+            if (Status::OK == isZSLModeAvailable(staticMeta, PRIV_REPROCESS)) {
+                ASSERT_TRUE(hasPrivToY8);
+            }
+            if (Status::OK == isZSLModeAvailable(staticMeta, YUV_REPROCESS)) {
+                ASSERT_TRUE(hasY8ToY8);
+                ASSERT_TRUE(hasY8ToBlob);
+            }
+        }
+
         free_camera_metadata(staticMeta);
         ret = session->close();
         ASSERT_TRUE(ret.isOk());
@@ -2874,9 +3222,14 @@
         sp<ICameraDeviceSession> session;
         sp<device::V3_3::ICameraDeviceSession> session3_3;
         sp<device::V3_4::ICameraDeviceSession> session3_4;
+        sp<device::V3_5::ICameraDeviceSession> session3_5;
         openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMetaBuffer /*out*/);
-        castSession(session, deviceVersion, &session3_3, &session3_4);
-        ASSERT_NE(session3_4, nullptr);
+        castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5);
+        if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_4) {
+            ASSERT_NE(session3_4, nullptr);
+        } else {
+            ASSERT_NE(session3_5, nullptr);
+        }
 
         std::unordered_set<int32_t> availableSessionKeys;
         auto rc = getSupportedKeys(staticMetaBuffer, ANDROID_REQUEST_AVAILABLE_SESSION_KEYS,
@@ -2915,17 +3268,29 @@
                                 StreamRotation::ROTATION_0};
         ::android::hardware::hidl_vec<V3_4::Stream> streams = {previewStream};
         ::android::hardware::camera::device::V3_4::StreamConfiguration config;
+        ::android::hardware::camera::device::V3_5::StreamConfiguration config3_5;
         config.streams = streams;
         config.operationMode = StreamConfigurationMode::NORMAL_MODE;
         const camera_metadata_t *sessionParamsBuffer = sessionParams.getAndLock();
         config.sessionParams.setToExternal(
                 reinterpret_cast<uint8_t *> (const_cast<camera_metadata_t *> (sessionParamsBuffer)),
                 get_camera_metadata_size(sessionParamsBuffer));
-        ret = session3_4->configureStreams_3_4(config,
-                [](Status s, device::V3_4::HalStreamConfiguration halConfig) {
-                    ASSERT_EQ(Status::OK, s);
-                    ASSERT_EQ(1u, halConfig.streams.size());
-                });
+        config3_5.v3_4 = config;
+        config3_5.streamConfigCounter = 0;
+        if (session3_5 != nullptr) {
+            ret = session3_5->configureStreams_3_5(config3_5,
+                    [](Status s, device::V3_4::HalStreamConfiguration halConfig) {
+                        ASSERT_EQ(Status::OK, s);
+                        ASSERT_EQ(1u, halConfig.streams.size());
+                    });
+        } else {
+            ret = session3_4->configureStreams_3_4(config,
+                    [](Status s, device::V3_4::HalStreamConfiguration halConfig) {
+                        ASSERT_EQ(Status::OK, s);
+                        ASSERT_EQ(1u, halConfig.streams.size());
+                    });
+        }
+
         ASSERT_TRUE(ret.isOk());
 
         free_camera_metadata(staticMetaBuffer);
@@ -2960,8 +3325,13 @@
         sp<ICameraDeviceSession> session;
         sp<device::V3_3::ICameraDeviceSession> session3_3;
         sp<device::V3_4::ICameraDeviceSession> session3_4;
-        openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/);
-        castSession(session, deviceVersion, &session3_3, &session3_4);
+        sp<device::V3_5::ICameraDeviceSession> session3_5;
+        sp<device::V3_2::ICameraDevice> cameraDevice;
+        sp<device::V3_5::ICameraDevice> cameraDevice3_5;
+        openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/,
+                &cameraDevice /*out*/);
+        castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5);
+        castDevice(cameraDevice, deviceVersion, &cameraDevice3_5);
 
         outputBlobStreams.clear();
         ASSERT_EQ(Status::OK,
@@ -2975,6 +3345,7 @@
         ASSERT_NE(0u, outputPreviewStreams.size());
 
         int32_t streamId = 0;
+        uint32_t streamConfigCounter = 0;
         for (auto& blobIter : outputBlobStreams) {
             for (auto& previewIter : outputPreviewStreams) {
                 V3_2::Stream previewStream = {streamId++,
@@ -2995,11 +3366,21 @@
                                      StreamRotation::ROTATION_0};
                 ::android::hardware::hidl_vec<V3_2::Stream> streams = {previewStream,
                                                                  blobStream};
+                ::android::hardware::camera::device::V3_5::StreamConfiguration config3_5;
                 ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4;
                 ::android::hardware::camera::device::V3_2::StreamConfiguration config3_2;
                 createStreamConfiguration(streams, StreamConfigurationMode::NORMAL_MODE,
-                                          &config3_2, &config3_4);
-                if (session3_4 != nullptr) {
+                                          &config3_2, &config3_4, &config3_5);
+                if (session3_5 != nullptr) {
+                    verifyStreamCombination(cameraDevice3_5, config3_4,
+                            /*expectedStatus*/ true);
+                    config3_5.streamConfigCounter = streamConfigCounter++;
+                    ret = session3_5->configureStreams_3_5(config3_5,
+                            [](Status s, device::V3_4::HalStreamConfiguration halConfig) {
+                                ASSERT_EQ(Status::OK, s);
+                                ASSERT_EQ(2u, halConfig.streams.size());
+                            });
+                } else if (session3_4 != nullptr) {
                     ret = session3_4->configureStreams_3_4(config3_4,
                             [](Status s, device::V3_4::HalStreamConfiguration halConfig) {
                                 ASSERT_EQ(Status::OK, s);
@@ -3049,8 +3430,13 @@
         sp<ICameraDeviceSession> session;
         sp<device::V3_3::ICameraDeviceSession> session3_3;
         sp<device::V3_4::ICameraDeviceSession> session3_4;
-        openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/);
-        castSession(session, deviceVersion, &session3_3, &session3_4);
+        sp<device::V3_5::ICameraDeviceSession> session3_5;
+        sp<device::V3_2::ICameraDevice> cameraDevice;
+        sp<device::V3_5::ICameraDevice> cameraDevice3_5;
+        openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/,
+                &cameraDevice /*out*/);
+        castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5);
+        castDevice(cameraDevice, deviceVersion, &cameraDevice3_5);
 
         Status rc = isConstrainedModeAvailable(staticMeta);
         if (Status::METHOD_NOT_SUPPORTED == rc) {
@@ -3065,6 +3451,7 @@
         ASSERT_EQ(Status::OK, rc);
 
         int32_t streamId = 0;
+        uint32_t streamConfigCounter = 0;
         V3_2::Stream stream = {streamId,
                          StreamType::OUTPUT,
                          static_cast<uint32_t>(hfrStream.width),
@@ -3074,11 +3461,22 @@
                          0,
                          StreamRotation::ROTATION_0};
         ::android::hardware::hidl_vec<V3_2::Stream> streams = {stream};
+        ::android::hardware::camera::device::V3_5::StreamConfiguration config3_5;
         ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4;
         ::android::hardware::camera::device::V3_2::StreamConfiguration config3_2;
         createStreamConfiguration(streams, StreamConfigurationMode::CONSTRAINED_HIGH_SPEED_MODE,
-                                  &config3_2, &config3_4);
-        if (session3_4 != nullptr) {
+                                  &config3_2, &config3_4, &config3_5);
+        if (session3_5 != nullptr) {
+            verifyStreamCombination(cameraDevice3_5, config3_4,
+                    /*expectedStatus*/ true);
+            config3_5.streamConfigCounter = streamConfigCounter++;
+            ret = session3_5->configureStreams_3_5(config3_5,
+                    [streamId](Status s, device::V3_4::HalStreamConfiguration halConfig) {
+                        ASSERT_EQ(Status::OK, s);
+                        ASSERT_EQ(1u, halConfig.streams.size());
+                        ASSERT_EQ(halConfig.streams[0].v3_3.v3_2.id, streamId);
+                    });
+        } else if (session3_4 != nullptr) {
             ret = session3_4->configureStreams_3_4(config3_4,
                     [streamId](Status s, device::V3_4::HalStreamConfiguration halConfig) {
                         ASSERT_EQ(Status::OK, s);
@@ -3112,8 +3510,15 @@
                   StreamRotation::ROTATION_0};
         streams[0] = stream;
         createStreamConfiguration(streams, StreamConfigurationMode::CONSTRAINED_HIGH_SPEED_MODE,
-                                  &config3_2, &config3_4);
-        if (session3_4 != nullptr) {
+                                  &config3_2, &config3_4, &config3_5);
+        if (session3_5 != nullptr) {
+            config3_5.streamConfigCounter = streamConfigCounter++;
+            ret = session3_5->configureStreams_3_5(config3_5,
+                    [](Status s, device::V3_4::HalStreamConfiguration) {
+                        ASSERT_TRUE((Status::ILLEGAL_ARGUMENT == s) ||
+                                (Status::INTERNAL_ERROR == s));
+                    });
+        } else if (session3_4 != nullptr) {
             ret = session3_4->configureStreams_3_4(config3_4,
                     [](Status s, device::V3_4::HalStreamConfiguration) {
                         ASSERT_TRUE((Status::ILLEGAL_ARGUMENT == s) ||
@@ -3144,8 +3549,14 @@
                   StreamRotation::ROTATION_0};
         streams[0] = stream;
         createStreamConfiguration(streams, StreamConfigurationMode::CONSTRAINED_HIGH_SPEED_MODE,
-                                  &config3_2, &config3_4);
-        if (session3_4 != nullptr) {
+                                  &config3_2, &config3_4, &config3_5);
+        if (session3_5 != nullptr) {
+            config3_5.streamConfigCounter = streamConfigCounter++;
+            ret = session3_5->configureStreams_3_5(config3_5,
+                    [](Status s, device::V3_4::HalStreamConfiguration) {
+                        ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s);
+                    });
+        } else if (session3_4 != nullptr) {
             ret = session3_4->configureStreams_3_4(config3_4,
                     [](Status s, device::V3_4::HalStreamConfiguration) {
                         ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s);
@@ -3173,8 +3584,14 @@
                   StreamRotation::ROTATION_0};
         streams[0] = stream;
         createStreamConfiguration(streams, StreamConfigurationMode::CONSTRAINED_HIGH_SPEED_MODE,
-                                  &config3_2, &config3_4);
-        if (session3_4 != nullptr) {
+                                  &config3_2, &config3_4, &config3_5);
+        if (session3_5 != nullptr) {
+            config3_5.streamConfigCounter = streamConfigCounter++;
+            ret = session3_5->configureStreams_3_5(config3_5,
+                    [](Status s, device::V3_4::HalStreamConfiguration) {
+                        ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s);
+                    });
+        } else if (session3_4 != nullptr) {
             ret = session3_4->configureStreams_3_4(config3_4,
                     [](Status s, device::V3_4::HalStreamConfiguration) {
                         ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s);
@@ -3224,8 +3641,13 @@
         sp<ICameraDeviceSession> session;
         sp<device::V3_3::ICameraDeviceSession> session3_3;
         sp<device::V3_4::ICameraDeviceSession> session3_4;
-        openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/);
-        castSession(session, deviceVersion, &session3_3, &session3_4);
+        sp<device::V3_5::ICameraDeviceSession> session3_5;
+        sp<device::V3_2::ICameraDevice> cameraDevice;
+        sp<device::V3_5::ICameraDevice> cameraDevice3_5;
+        openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/,
+                &cameraDevice /*out*/);
+        castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5);
+        castDevice(cameraDevice, deviceVersion, &cameraDevice3_5);
 
         outputBlobStreams.clear();
         ASSERT_EQ(Status::OK,
@@ -3240,6 +3662,7 @@
         ASSERT_NE(0u, outputVideoStreams.size());
 
         int32_t streamId = 0;
+        uint32_t streamConfigCounter = 0;
         for (auto& blobIter : outputBlobStreams) {
             for (auto& videoIter : outputVideoStreams) {
                 V3_2::Stream videoStream = {streamId++,
@@ -3259,11 +3682,21 @@
                                      static_cast<V3_2::DataspaceFlags>(Dataspace::V0_JFIF),
                                      StreamRotation::ROTATION_0};
                 ::android::hardware::hidl_vec<V3_2::Stream> streams = {videoStream, blobStream};
+                ::android::hardware::camera::device::V3_5::StreamConfiguration config3_5;
                 ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4;
                 ::android::hardware::camera::device::V3_2::StreamConfiguration config3_2;
                 createStreamConfiguration(streams, StreamConfigurationMode::NORMAL_MODE,
-                                          &config3_2, &config3_4);
-                if (session3_4 != nullptr) {
+                                          &config3_2, &config3_4, &config3_5);
+                if (session3_5 != nullptr) {
+                    verifyStreamCombination(cameraDevice3_5, config3_4,
+                            /*expectedStatus*/ true);
+                    config3_5.streamConfigCounter = streamConfigCounter++;
+                    ret = session3_5->configureStreams_3_5(config3_5,
+                            [](Status s, device::V3_4::HalStreamConfiguration halConfig) {
+                                ASSERT_EQ(Status::OK, s);
+                                ASSERT_EQ(2u, halConfig.streams.size());
+                            });
+                } else if (session3_4 != nullptr) {
                     ret = session3_4->configureStreams_3_4(config3_4,
                             [](Status s, device::V3_4::HalStreamConfiguration halConfig) {
                                 ASSERT_EQ(Status::OK, s);
@@ -3314,12 +3747,14 @@
         V3_2::Stream previewStream;
         HalStreamConfiguration halStreamConfig;
         sp<ICameraDeviceSession> session;
+        sp<DeviceCb> cb;
         bool supportsPartialResults = false;
+        bool useHalBufManager = false;
         uint32_t partialResultCount = 0;
         configurePreviewStream(name, deviceVersion, mProvider, &previewThreshold, &session /*out*/,
                 &previewStream /*out*/, &halStreamConfig /*out*/,
                 &supportsPartialResults /*out*/,
-                &partialResultCount /*out*/);
+                &partialResultCount /*out*/, &useHalBufManager /*out*/, &cb /*out*/);
 
         std::shared_ptr<ResultMetadataQueue> resultQueue;
         auto resultQueueRet =
@@ -3350,17 +3785,26 @@
         ASSERT_TRUE(ret.isOk());
 
         hidl_handle buffer_handle;
-        allocateGraphicBuffer(previewStream.width, previewStream.height,
-                android_convertGralloc1To0Usage(halStreamConfig.streams[0].producerUsage,
-                    halStreamConfig.streams[0].consumerUsage),
-                halStreamConfig.streams[0].overrideFormat, &buffer_handle);
-
-        StreamBuffer outputBuffer = {halStreamConfig.streams[0].id,
-                                     bufferId,
-                                     buffer_handle,
-                                     BufferStatus::OK,
-                                     nullptr,
-                                     nullptr};
+        StreamBuffer outputBuffer;
+        if (useHalBufManager) {
+            outputBuffer = {halStreamConfig.streams[0].id,
+                            /*bufferId*/ 0,
+                            buffer_handle,
+                            BufferStatus::OK,
+                            nullptr,
+                            nullptr};
+        } else {
+            allocateGraphicBuffer(previewStream.width, previewStream.height,
+                    android_convertGralloc1To0Usage(halStreamConfig.streams[0].producerUsage,
+                        halStreamConfig.streams[0].consumerUsage),
+                    halStreamConfig.streams[0].overrideFormat, &buffer_handle);
+            outputBuffer = {halStreamConfig.streams[0].id,
+                            bufferId,
+                            buffer_handle,
+                            BufferStatus::OK,
+                            nullptr,
+                            nullptr};
+        }
         ::android::hardware::hidl_vec<StreamBuffer> outputBuffers = {outputBuffer};
         StreamBuffer emptyInputBuffer = {-1, 0, nullptr, BufferStatus::ERROR, nullptr,
                                          nullptr};
@@ -3440,6 +3884,10 @@
             ASSERT_EQ(previewStream.id, inflightReq.resultOutputBuffers[0].streamId);
         }
 
+        if (useHalBufManager) {
+            verifyBuffersReturned(session, deviceVersion, previewStream.id, cb);
+        }
+
         ret = session->close();
         ASSERT_TRUE(ret.isOk());
     }
@@ -3521,12 +3969,16 @@
 
         V3_4::HalStreamConfiguration halStreamConfig;
         bool supportsPartialResults = false;
+        bool useHalBufManager = false;
         uint32_t partialResultCount = 0;
         V3_2::Stream previewStream;
         sp<device::V3_4::ICameraDeviceSession> session3_4;
+        sp<device::V3_5::ICameraDeviceSession> session3_5;
+        sp<DeviceCb> cb;
         configurePreviewStreams3_4(name, deviceVersion, mProvider, &previewThreshold, physicalIds,
-                &session3_4, &previewStream, &halStreamConfig /*out*/,
-                &supportsPartialResults /*out*/, &partialResultCount /*out*/);
+                &session3_4, &session3_5, &previewStream, &halStreamConfig /*out*/,
+                &supportsPartialResults /*out*/, &partialResultCount /*out*/,
+                &useHalBufManager /*out*/, &cb /*out*/);
         ASSERT_NE(session3_4, nullptr);
 
         std::shared_ptr<ResultMetadataQueue> resultQueue;
@@ -3555,14 +4007,19 @@
         size_t k = 0;
         for (const auto& halStream : halStreamConfig.streams) {
             hidl_handle buffer_handle;
-            allocateGraphicBuffer(previewStream.width, previewStream.height,
-                    android_convertGralloc1To0Usage(halStream.v3_3.v3_2.producerUsage,
-                        halStream.v3_3.v3_2.consumerUsage),
-                    halStream.v3_3.v3_2.overrideFormat, &buffer_handle);
-            graphicBuffers.push_back(buffer_handle);
-            outputBuffers[k] = {halStream.v3_3.v3_2.id, bufferId, buffer_handle,
-                BufferStatus::OK, nullptr, nullptr};
-            bufferId++;
+            if (useHalBufManager) {
+                outputBuffers[k] = {halStream.v3_3.v3_2.id, /*bufferId*/0, buffer_handle,
+                    BufferStatus::OK, nullptr, nullptr};
+            } else {
+                allocateGraphicBuffer(previewStream.width, previewStream.height,
+                        android_convertGralloc1To0Usage(halStream.v3_3.v3_2.producerUsage,
+                            halStream.v3_3.v3_2.consumerUsage),
+                        halStream.v3_3.v3_2.overrideFormat, &buffer_handle);
+                graphicBuffers.push_back(buffer_handle);
+                outputBuffers[k] = {halStream.v3_3.v3_2.id, bufferId, buffer_handle,
+                    BufferStatus::OK, nullptr, nullptr};
+                bufferId++;
+            }
             k++;
         }
         hidl_vec<V3_4::PhysicalCameraSetting> camSettings(1);
@@ -3664,6 +4121,15 @@
 
         defaultPreviewSettings.unlock(settingsBuffer);
         filteredSettings.unlock(filteredSettingsBuffer);
+
+        if (useHalBufManager) {
+            hidl_vec<int32_t> streamIds(halStreamConfig.streams.size());
+            for (size_t i = 0; i < streamIds.size(); i++) {
+                streamIds[i] = halStreamConfig.streams[i].v3_3.v3_2.id;
+            }
+            verifyBuffersReturned(session3_4, streamIds, cb);
+        }
+
         ret = session3_4->close();
         ASSERT_TRUE(ret.isOk());
     }
@@ -3712,12 +4178,15 @@
         ASSERT_TRUE(ret.isOk());
 
         bool supportsPartialResults = false;
+        bool useHalBufManager = false;
         uint32_t partialResultCount = 0;
         V3_2::Stream previewStream;
         HalStreamConfiguration halStreamConfig;
+        sp<DeviceCb> cb;
         configurePreviewStream(name, deviceVersion, mProvider, &previewThreshold,
                 &session /*out*/, &previewStream /*out*/, &halStreamConfig /*out*/,
-                &supportsPartialResults /*out*/, &partialResultCount /*out*/);
+                &supportsPartialResults /*out*/, &partialResultCount /*out*/,
+                &useHalBufManager /*out*/, &cb /*out*/);
         std::shared_ptr<ResultMetadataQueue> resultQueue;
 
         auto resultQueueRet = session->getCaptureResultMetadataQueue(
@@ -3751,13 +4220,18 @@
             std::unique_lock<std::mutex> l(mLock);
 
             isoValues[i] = ((i % 2) == 0) ? isoRange.data.i32[0] : isoRange.data.i32[1];
-            allocateGraphicBuffer(previewStream.width, previewStream.height,
-                    android_convertGralloc1To0Usage(halStreamConfig.streams[0].producerUsage,
-                        halStreamConfig.streams[0].consumerUsage),
-                    halStreamConfig.streams[0].overrideFormat, &buffers[i]);
+            if (useHalBufManager) {
+                outputBuffers[i] = {halStreamConfig.streams[0].id, /*bufferId*/0,
+                    nullptr, BufferStatus::OK, nullptr, nullptr};
+            } else {
+                allocateGraphicBuffer(previewStream.width, previewStream.height,
+                        android_convertGralloc1To0Usage(halStreamConfig.streams[0].producerUsage,
+                            halStreamConfig.streams[0].consumerUsage),
+                        halStreamConfig.streams[0].overrideFormat, &buffers[i]);
+                outputBuffers[i] = {halStreamConfig.streams[0].id, bufferId + i,
+                    buffers[i], BufferStatus::OK, nullptr, nullptr};
+            }
 
-            outputBuffers[i] = {halStreamConfig.streams[0].id, bufferId + i,
-                buffers[i], BufferStatus::OK, nullptr, nullptr};
             requestMeta.append(reinterpret_cast<camera_metadata_t *> (settings.data()));
 
             // Disable all 3A routines
@@ -3810,6 +4284,9 @@
                         std::round(isoValues[i]*isoTol));
         }
 
+        if (useHalBufManager) {
+            verifyBuffersReturned(session, deviceVersion, previewStream.id, cb);
+        }
         ret = session->close();
         ASSERT_TRUE(ret.isOk());
     }
@@ -3839,18 +4316,25 @@
         V3_2::Stream previewStream;
         HalStreamConfiguration halStreamConfig;
         sp<ICameraDeviceSession> session;
+        sp<DeviceCb> cb;
         bool supportsPartialResults = false;
+        bool useHalBufManager = false;
         uint32_t partialResultCount = 0;
         configurePreviewStream(name, deviceVersion, mProvider, &previewThreshold, &session /*out*/,
                 &previewStream /*out*/, &halStreamConfig /*out*/,
                 &supportsPartialResults /*out*/,
-                &partialResultCount /*out*/);
+                &partialResultCount /*out*/, &useHalBufManager /*out*/, &cb /*out*/);
 
         hidl_handle buffer_handle;
-        allocateGraphicBuffer(previewStream.width, previewStream.height,
-                android_convertGralloc1To0Usage(halStreamConfig.streams[0].producerUsage,
-                    halStreamConfig.streams[0].consumerUsage),
-                halStreamConfig.streams[0].overrideFormat, &buffer_handle);
+
+        if (useHalBufManager) {
+            bufferId = 0;
+        } else {
+            allocateGraphicBuffer(previewStream.width, previewStream.height,
+                    android_convertGralloc1To0Usage(halStreamConfig.streams[0].producerUsage,
+                        halStreamConfig.streams[0].consumerUsage),
+                    halStreamConfig.streams[0].overrideFormat, &buffer_handle);
+        }
 
         StreamBuffer outputBuffer = {halStreamConfig.streams[0].id,
                                      bufferId,
@@ -3906,12 +4390,14 @@
         V3_2::Stream previewStream;
         HalStreamConfiguration halStreamConfig;
         sp<ICameraDeviceSession> session;
+        sp<DeviceCb> cb;
         bool supportsPartialResults = false;
+        bool useHalBufManager = false;
         uint32_t partialResultCount = 0;
         configurePreviewStream(name, deviceVersion, mProvider, &previewThreshold, &session /*out*/,
                 &previewStream /*out*/, &halStreamConfig /*out*/,
                 &supportsPartialResults /*out*/,
-                &partialResultCount /*out*/);
+                &partialResultCount /*out*/, &useHalBufManager /*out*/, &cb /*out*/);
 
         RequestTemplate reqTemplate = RequestTemplate::PREVIEW;
         Return<void> ret;
@@ -3970,12 +4456,14 @@
         V3_2::Stream previewStream;
         HalStreamConfiguration halStreamConfig;
         sp<ICameraDeviceSession> session;
+        sp<DeviceCb> cb;
         bool supportsPartialResults = false;
+        bool useHalBufManager = false;
         uint32_t partialResultCount = 0;
         configurePreviewStream(name, deviceVersion, mProvider, &previewThreshold, &session /*out*/,
                 &previewStream /*out*/, &halStreamConfig /*out*/,
                 &supportsPartialResults /*out*/,
-                &partialResultCount /*out*/);
+                &partialResultCount /*out*/, &useHalBufManager /*out*/, &cb /*out*/);
 
         std::shared_ptr<ResultMetadataQueue> resultQueue;
         auto resultQueueRet =
@@ -4005,10 +4493,14 @@
         ASSERT_TRUE(ret.isOk());
 
         hidl_handle buffer_handle;
-        allocateGraphicBuffer(previewStream.width, previewStream.height,
-                android_convertGralloc1To0Usage(halStreamConfig.streams[0].producerUsage,
-                    halStreamConfig.streams[0].consumerUsage),
-                halStreamConfig.streams[0].overrideFormat, &buffer_handle);
+        if (useHalBufManager) {
+            bufferId = 0;
+        } else {
+            allocateGraphicBuffer(previewStream.width, previewStream.height,
+                    android_convertGralloc1To0Usage(halStreamConfig.streams[0].producerUsage,
+                        halStreamConfig.streams[0].consumerUsage),
+                    halStreamConfig.streams[0].overrideFormat, &buffer_handle);
+        }
 
         StreamBuffer outputBuffer = {halStreamConfig.streams[0].id,
                                      bufferId,
@@ -4075,6 +4567,10 @@
             }
         }
 
+        if (useHalBufManager) {
+            verifyBuffersReturned(session, deviceVersion, previewStream.id, cb);
+        }
+
         ret = session->close();
         ASSERT_TRUE(ret.isOk());
     }
@@ -4100,12 +4596,14 @@
         V3_2::Stream previewStream;
         HalStreamConfiguration halStreamConfig;
         sp<ICameraDeviceSession> session;
+        sp<DeviceCb> cb;
         bool supportsPartialResults = false;
+        bool useHalBufManager = false;
         uint32_t partialResultCount = 0;
         configurePreviewStream(name, deviceVersion, mProvider, &previewThreshold, &session /*out*/,
                 &previewStream /*out*/, &halStreamConfig /*out*/,
                 &supportsPartialResults /*out*/,
-                &partialResultCount /*out*/);
+                &partialResultCount /*out*/, &useHalBufManager /*out*/, &cb /*out*/);
 
         Return<Status> returnStatus = session->flush();
         ASSERT_TRUE(returnStatus.isOk());
@@ -4325,6 +4823,16 @@
 // Check whether ZSL is available using the static camera
 // characteristics.
 Status CameraHidlTest::isZSLModeAvailable(const camera_metadata_t *staticMeta) {
+    if (Status::OK == isZSLModeAvailable(staticMeta, PRIV_REPROCESS)) {
+        return Status::OK;
+    } else {
+        return isZSLModeAvailable(staticMeta, YUV_REPROCESS);
+    }
+}
+
+Status CameraHidlTest::isZSLModeAvailable(const camera_metadata_t *staticMeta,
+        ReprocessType reprocType) {
+
     Status ret = Status::METHOD_NOT_SUPPORTED;
     if (nullptr == staticMeta) {
         return Status::ILLEGAL_ARGUMENT;
@@ -4338,10 +4846,34 @@
     }
 
     for (size_t i = 0; i < entry.count; i++) {
-        if ((ANDROID_REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING ==
-                entry.data.u8[i]) ||
-                (ANDROID_REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING ==
-                        entry.data.u8[i]) ){
+        if ((reprocType == PRIV_REPROCESS &&
+                ANDROID_REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING == entry.data.u8[i]) ||
+                (reprocType == YUV_REPROCESS &&
+                ANDROID_REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING == entry.data.u8[i])) {
+            ret = Status::OK;
+            break;
+        }
+    }
+
+    return ret;
+}
+
+// Check whether this is a monochrome camera using the static camera characteristics.
+Status CameraHidlTest::isMonochromeCamera(const camera_metadata_t *staticMeta) {
+    Status ret = Status::METHOD_NOT_SUPPORTED;
+    if (nullptr == staticMeta) {
+        return Status::ILLEGAL_ARGUMENT;
+    }
+
+    camera_metadata_ro_entry entry;
+    int rc = find_camera_metadata_ro_entry(staticMeta,
+            ANDROID_REQUEST_AVAILABLE_CAPABILITIES, &entry);
+    if (0 != rc) {
+        return Status::ILLEGAL_ARGUMENT;
+    }
+
+    for (size_t i = 0; i < entry.count; i++) {
+        if (ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME == entry.data.u8[i]) {
             ret = Status::OK;
             break;
         }
@@ -4413,9 +4945,11 @@
         const ::android::hardware::hidl_vec<V3_2::Stream>& streams3_2,
         StreamConfigurationMode configMode,
         ::android::hardware::camera::device::V3_2::StreamConfiguration *config3_2 /*out*/,
-        ::android::hardware::camera::device::V3_4::StreamConfiguration *config3_4 /*out*/) {
+        ::android::hardware::camera::device::V3_4::StreamConfiguration *config3_4 /*out*/,
+        ::android::hardware::camera::device::V3_5::StreamConfiguration *config3_5 /*out*/) {
     ASSERT_NE(nullptr, config3_2);
     ASSERT_NE(nullptr, config3_4);
+    ASSERT_NE(nullptr, config3_5);
 
     ::android::hardware::hidl_vec<V3_4::Stream> streams3_4(streams3_2.size());
     size_t idx = 0;
@@ -4424,7 +4958,9 @@
         stream.v3_2 = stream3_2;
         streams3_4[idx++] = stream;
     }
-    *config3_4 = {streams3_4, configMode, {}};
+    // Caller is responsible to fill in non-zero config3_5->streamConfigCounter after this returns
+    *config3_5 = {{streams3_4, configMode, {}}, 0};
+    *config3_4 = config3_5->v3_4;
     *config3_2 = {streams3_2, configMode};
 }
 
@@ -4434,15 +4970,22 @@
         const AvailableStream *previewThreshold,
         const std::unordered_set<std::string>& physicalIds,
         sp<device::V3_4::ICameraDeviceSession> *session3_4 /*out*/,
+        sp<device::V3_5::ICameraDeviceSession> *session3_5 /*out*/,
         V3_2::Stream *previewStream /*out*/,
         device::V3_4::HalStreamConfiguration *halStreamConfig /*out*/,
         bool *supportsPartialResults /*out*/,
-        uint32_t *partialResultCount /*out*/) {
+        uint32_t *partialResultCount /*out*/,
+        bool *useHalBufManager /*out*/,
+        sp<DeviceCb> *outCb /*out*/,
+        uint32_t streamConfigCounter) {
     ASSERT_NE(nullptr, session3_4);
+    ASSERT_NE(nullptr, session3_5);
     ASSERT_NE(nullptr, halStreamConfig);
     ASSERT_NE(nullptr, previewStream);
     ASSERT_NE(nullptr, supportsPartialResults);
     ASSERT_NE(nullptr, partialResultCount);
+    ASSERT_NE(nullptr, useHalBufManager);
+    ASSERT_NE(nullptr, outCb);
     ASSERT_FALSE(physicalIds.empty());
 
     std::vector<AvailableStream> outputPreviewStreams;
@@ -4460,22 +5003,6 @@
         });
     ASSERT_TRUE(ret.isOk());
 
-    sp<DeviceCb> cb = new DeviceCb(this);
-    sp<ICameraDeviceSession> session;
-    ret = device3_x->open(
-        cb,
-        [&session](auto status, const auto& newSession) {
-            ALOGI("device::open returns status:%d", (int)status);
-            ASSERT_EQ(Status::OK, status);
-            ASSERT_NE(newSession, nullptr);
-            session = newSession;
-        });
-    ASSERT_TRUE(ret.isOk());
-
-    sp<device::V3_3::ICameraDeviceSession> session3_3;
-    castSession(session, deviceVersion, &session3_3, session3_4);
-    ASSERT_NE(nullptr, session3_4);
-
     camera_metadata_t *staticMeta;
     ret = device3_x->getCameraCharacteristics([&] (Status s,
             CameraMetadata metadata) {
@@ -4494,6 +5021,33 @@
         *supportsPartialResults = (*partialResultCount > 1);
     }
 
+    bool checkMonochromeResultTags = Status::OK == isMonochromeCamera(staticMeta) &&
+            deviceVersion >= CAMERA_DEVICE_API_VERSION_3_5;
+    sp<DeviceCb> cb = new DeviceCb(this, checkMonochromeResultTags);
+    sp<ICameraDeviceSession> session;
+    ret = device3_x->open(
+        cb,
+        [&session](auto status, const auto& newSession) {
+            ALOGI("device::open returns status:%d", (int)status);
+            ASSERT_EQ(Status::OK, status);
+            ASSERT_NE(newSession, nullptr);
+            session = newSession;
+        });
+    ASSERT_TRUE(ret.isOk());
+    *outCb = cb;
+
+    sp<device::V3_3::ICameraDeviceSession> session3_3;
+    castSession(session, deviceVersion, &session3_3, session3_4, session3_5);
+    ASSERT_NE(nullptr, (*session3_4).get());
+
+    *useHalBufManager = false;
+    status = find_camera_metadata_ro_entry(staticMeta,
+            ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION, &entry);
+    if ((0 == status) && (entry.count == 1)) {
+        *useHalBufManager = (entry.data.u8[0] ==
+            ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_HIDL_DEVICE_3_5);
+    }
+
     outputPreviewStreams.clear();
     auto rc = getAvailableOutputStreams(staticMeta,
             outputPreviewStreams, previewThreshold);
@@ -4514,6 +5068,7 @@
     }
 
     ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4;
+    ::android::hardware::camera::device::V3_5::StreamConfiguration config3_5;
     config3_4 = {streams3_4, StreamConfigurationMode::NORMAL_MODE, {}};
     RequestTemplate reqTemplate = RequestTemplate::PREVIEW;
     ret = (*session3_4)->constructDefaultRequestSettings(reqTemplate,
@@ -4523,12 +5078,32 @@
             });
     ASSERT_TRUE(ret.isOk());
 
-    ret = (*session3_4)->configureStreams_3_4(config3_4,
-            [&] (Status s, device::V3_4::HalStreamConfiguration halConfig) {
-            ASSERT_EQ(Status::OK, s);
-            ASSERT_EQ(physicalIds.size(), halConfig.streams.size());
-            *halStreamConfig = halConfig;
-            });
+    if (*session3_5 != nullptr) {
+        config3_5.v3_4 = config3_4;
+        config3_5.streamConfigCounter = streamConfigCounter;
+        ret = (*session3_5)->configureStreams_3_5(config3_5,
+                [&] (Status s, device::V3_4::HalStreamConfiguration halConfig) {
+                    ASSERT_EQ(Status::OK, s);
+                    ASSERT_EQ(physicalIds.size(), halConfig.streams.size());
+                    *halStreamConfig = halConfig;
+                    if (*useHalBufManager) {
+                        hidl_vec<V3_2::Stream> streams(physicalIds.size());
+                        hidl_vec<V3_2::HalStream> halStreams(physicalIds.size());
+                        for (size_t i = 0; i < physicalIds.size(); i++) {
+                            streams[i] = streams3_4[i].v3_2;
+                            halStreams[i] = halConfig.streams[i].v3_3.v3_2;
+                        }
+                        cb->setCurrentStreamConfig(streams, halStreams);
+                    }
+                });
+    } else {
+        ret = (*session3_4)->configureStreams_3_4(config3_4,
+                [&] (Status s, device::V3_4::HalStreamConfiguration halConfig) {
+                ASSERT_EQ(Status::OK, s);
+                ASSERT_EQ(physicalIds.size(), halConfig.streams.size());
+                *halStreamConfig = halConfig;
+                });
+    }
     *previewStream = streams3_4[0].v3_2;
     ASSERT_TRUE(ret.isOk());
 }
@@ -4541,12 +5116,17 @@
         V3_2::Stream *previewStream /*out*/,
         HalStreamConfiguration *halStreamConfig /*out*/,
         bool *supportsPartialResults /*out*/,
-        uint32_t *partialResultCount /*out*/) {
+        uint32_t *partialResultCount /*out*/,
+        bool *useHalBufManager /*out*/,
+        sp<DeviceCb> *outCb /*out*/,
+        uint32_t streamConfigCounter) {
     ASSERT_NE(nullptr, session);
     ASSERT_NE(nullptr, previewStream);
     ASSERT_NE(nullptr, halStreamConfig);
     ASSERT_NE(nullptr, supportsPartialResults);
     ASSERT_NE(nullptr, partialResultCount);
+    ASSERT_NE(nullptr, useHalBufManager);
+    ASSERT_NE(nullptr, outCb);
 
     std::vector<AvailableStream> outputPreviewStreams;
     ::android::sp<ICameraDevice> device3_x;
@@ -4563,21 +5143,6 @@
         });
     ASSERT_TRUE(ret.isOk());
 
-    sp<DeviceCb> cb = new DeviceCb(this);
-    ret = device3_x->open(
-        cb,
-        [&](auto status, const auto& newSession) {
-            ALOGI("device::open returns status:%d", (int)status);
-            ASSERT_EQ(Status::OK, status);
-            ASSERT_NE(newSession, nullptr);
-            *session = newSession;
-        });
-    ASSERT_TRUE(ret.isOk());
-
-    sp<device::V3_3::ICameraDeviceSession> session3_3;
-    sp<device::V3_4::ICameraDeviceSession> session3_4;
-    castSession(*session, deviceVersion, &session3_3, &session3_4);
-
     camera_metadata_t *staticMeta;
     ret = device3_x->getCameraCharacteristics([&] (Status s,
             CameraMetadata metadata) {
@@ -4596,6 +5161,33 @@
         *supportsPartialResults = (*partialResultCount > 1);
     }
 
+    bool checkMonochromeResultTags = Status::OK == isMonochromeCamera(staticMeta) &&
+            deviceVersion >= CAMERA_DEVICE_API_VERSION_3_5;
+    sp<DeviceCb> cb = new DeviceCb(this, checkMonochromeResultTags);
+    ret = device3_x->open(
+        cb,
+        [&](auto status, const auto& newSession) {
+            ALOGI("device::open returns status:%d", (int)status);
+            ASSERT_EQ(Status::OK, status);
+            ASSERT_NE(newSession, nullptr);
+            *session = newSession;
+        });
+    ASSERT_TRUE(ret.isOk());
+    *outCb = cb;
+
+    sp<device::V3_3::ICameraDeviceSession> session3_3;
+    sp<device::V3_4::ICameraDeviceSession> session3_4;
+    sp<device::V3_5::ICameraDeviceSession> session3_5;
+    castSession(*session, deviceVersion, &session3_3, &session3_4, &session3_5);
+
+    *useHalBufManager = false;
+    status = find_camera_metadata_ro_entry(staticMeta,
+            ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION, &entry);
+    if ((0 == status) && (entry.count == 1)) {
+        *useHalBufManager = (entry.data.u8[0] ==
+            ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_HIDL_DEVICE_3_5);
+    }
+
     outputPreviewStreams.clear();
     auto rc = getAvailableOutputStreams(staticMeta,
             outputPreviewStreams, previewThreshold);
@@ -4611,9 +5203,33 @@
     ::android::hardware::hidl_vec<V3_2::Stream> streams3_2 = {stream3_2};
     ::android::hardware::camera::device::V3_2::StreamConfiguration config3_2;
     ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4;
+    ::android::hardware::camera::device::V3_5::StreamConfiguration config3_5;
     createStreamConfiguration(streams3_2, StreamConfigurationMode::NORMAL_MODE,
-                              &config3_2, &config3_4);
-    if (session3_4 != nullptr) {
+                              &config3_2, &config3_4, &config3_5);
+    if (session3_5 != nullptr) {
+        RequestTemplate reqTemplate = RequestTemplate::PREVIEW;
+        ret = session3_5->constructDefaultRequestSettings(reqTemplate,
+                                                       [&config3_5](auto status, const auto& req) {
+                                                           ASSERT_EQ(Status::OK, status);
+                                                           config3_5.v3_4.sessionParams = req;
+                                                       });
+        ASSERT_TRUE(ret.isOk());
+        config3_5.streamConfigCounter = streamConfigCounter;
+        ret = session3_5->configureStreams_3_5(config3_5,
+                [&] (Status s, device::V3_4::HalStreamConfiguration halConfig) {
+                    ASSERT_EQ(Status::OK, s);
+                    ASSERT_EQ(1u, halConfig.streams.size());
+                    halStreamConfig->streams.resize(1);
+                    halStreamConfig->streams[0] = halConfig.streams[0].v3_3.v3_2;
+                    if (*useHalBufManager) {
+                        hidl_vec<V3_2::Stream> streams(1);
+                        hidl_vec<V3_2::HalStream> halStreams(1);
+                        streams[0] = stream3_2;
+                        halStreams[0] = halConfig.streams[0].v3_3.v3_2;
+                        cb->setCurrentStreamConfig(streams, halStreams);
+                    }
+                });
+    } else if (session3_4 != nullptr) {
         RequestTemplate reqTemplate = RequestTemplate::PREVIEW;
         ret = session3_4->constructDefaultRequestSettings(reqTemplate,
                                                        [&config3_4](auto status, const auto& req) {
@@ -4652,21 +5268,38 @@
     ASSERT_TRUE(ret.isOk());
 }
 
+void CameraHidlTest::castDevice(const sp<device::V3_2::ICameraDevice> &device,
+        int32_t deviceVersion, sp<device::V3_5::ICameraDevice> *device3_5/*out*/) {
+    ASSERT_NE(nullptr, device3_5);
+    if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_5) {
+        auto castResult = device::V3_5::ICameraDevice::castFrom(device);
+        ASSERT_TRUE(castResult.isOk());
+        *device3_5 = castResult;
+    }
+}
+
 //Cast camera device session to corresponding version
 void CameraHidlTest::castSession(const sp<ICameraDeviceSession> &session, int32_t deviceVersion,
         sp<device::V3_3::ICameraDeviceSession> *session3_3 /*out*/,
-        sp<device::V3_4::ICameraDeviceSession> *session3_4 /*out*/) {
+        sp<device::V3_4::ICameraDeviceSession> *session3_4 /*out*/,
+        sp<device::V3_5::ICameraDeviceSession> *session3_5 /*out*/) {
     ASSERT_NE(nullptr, session3_3);
     ASSERT_NE(nullptr, session3_4);
+    ASSERT_NE(nullptr, session3_5);
 
     switch (deviceVersion) {
-        case CAMERA_DEVICE_API_VERSION_3_5:
+        case CAMERA_DEVICE_API_VERSION_3_5: {
+            auto castResult = device::V3_5::ICameraDeviceSession::castFrom(session);
+            ASSERT_TRUE(castResult.isOk());
+            *session3_5 = castResult;
+        }
+        [[fallthrough]];
         case CAMERA_DEVICE_API_VERSION_3_4: {
             auto castResult = device::V3_4::ICameraDeviceSession::castFrom(session);
             ASSERT_TRUE(castResult.isOk());
             *session3_4 = castResult;
-            break;
         }
+        [[fallthrough]];
         case CAMERA_DEVICE_API_VERSION_3_3: {
             auto castResult = device::V3_3::ICameraDeviceSession::castFrom(session);
             ASSERT_TRUE(castResult.isOk());
@@ -4679,6 +5312,21 @@
     }
 }
 
+void CameraHidlTest::verifyStreamCombination(sp<device::V3_5::ICameraDevice> cameraDevice3_5,
+        const ::android::hardware::camera::device::V3_4::StreamConfiguration &config3_4,
+        bool expectedStatus) {
+    if (cameraDevice3_5.get() != nullptr) {
+        auto ret = cameraDevice3_5->isStreamCombinationSupported(config3_4,
+                [expectedStatus] (Status s, bool combStatus) {
+                    ASSERT_TRUE((Status::OK == s) || (Status::METHOD_NOT_SUPPORTED == s));
+                    if (Status::OK == s) {
+                        ASSERT_TRUE(combStatus == expectedStatus);
+                    }
+                });
+        ASSERT_TRUE(ret.isOk());
+    }
+}
+
 // Verify logical camera static metadata
 void CameraHidlTest::verifyLogicalCameraMetadata(const std::string& cameraName,
         const ::android::sp<::android::hardware::camera::device::V3_2::ICameraDevice>& device,
@@ -4723,6 +5371,7 @@
         Return<void> ret = device3_5->getPhysicalCameraCharacteristics(physicalId,
                 [&](auto status, const auto& chars) {
             verifyCameraCharacteristics(status, chars);
+            verifyMonochromeCharacteristics(chars, deviceVersion);
         });
         ASSERT_TRUE(ret.isOk());
 
@@ -4774,11 +5423,182 @@
     }
 }
 
+void CameraHidlTest::verifyMonochromeCharacteristics(const CameraMetadata& chars,
+        int deviceVersion) {
+    const camera_metadata_t* metadata = (camera_metadata_t*)chars.data();
+    Status rc = isMonochromeCamera(metadata);
+    if (Status::METHOD_NOT_SUPPORTED == rc) {
+        return;
+    }
+    ASSERT_EQ(Status::OK, rc);
+
+    camera_metadata_ro_entry entry;
+    // Check capabilities
+    int retcode = find_camera_metadata_ro_entry(metadata,
+                ANDROID_REQUEST_AVAILABLE_CAPABILITIES, &entry);
+    if ((0 == retcode) && (entry.count > 0)) {
+        ASSERT_EQ(std::find(entry.data.u8, entry.data.u8 + entry.count,
+                ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING),
+                entry.data.u8 + entry.count);
+        if (deviceVersion < CAMERA_DEVICE_API_VERSION_3_5) {
+            ASSERT_EQ(std::find(entry.data.u8, entry.data.u8 + entry.count,
+                    ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW),
+                    entry.data.u8 + entry.count);
+        }
+    }
+
+    if (deviceVersion >= CAMERA_DEVICE_API_VERSION_3_5) {
+        // Check Cfa
+        retcode = find_camera_metadata_ro_entry(metadata,
+                ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, &entry);
+        if ((0 == retcode) && (entry.count == 1)) {
+            ASSERT_TRUE(entry.data.i32[0] == static_cast<int32_t>(
+                    CameraMetadataEnumAndroidSensorInfoColorFilterArrangement::ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_MONO)
+                    || entry.data.i32[0] == static_cast<int32_t>(
+                    CameraMetadataEnumAndroidSensorInfoColorFilterArrangement::ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_NIR));
+        }
+
+        // Check availableRequestKeys
+        retcode = find_camera_metadata_ro_entry(metadata,
+                ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, &entry);
+        if ((0 == retcode) && (entry.count > 0)) {
+            for (size_t i = 0; i < entry.count; i++) {
+                ASSERT_NE(entry.data.i32[i], ANDROID_COLOR_CORRECTION_MODE);
+                ASSERT_NE(entry.data.i32[i], ANDROID_COLOR_CORRECTION_TRANSFORM);
+                ASSERT_NE(entry.data.i32[i], ANDROID_COLOR_CORRECTION_GAINS);
+            }
+        } else {
+            ADD_FAILURE() << "Get camera availableRequestKeys failed!";
+        }
+
+        // Check availableResultKeys
+        retcode = find_camera_metadata_ro_entry(metadata,
+                ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, &entry);
+        if ((0 == retcode) && (entry.count > 0)) {
+            for (size_t i = 0; i < entry.count; i++) {
+                ASSERT_NE(entry.data.i32[i], ANDROID_SENSOR_GREEN_SPLIT);
+                ASSERT_NE(entry.data.i32[i], ANDROID_SENSOR_NEUTRAL_COLOR_POINT);
+                ASSERT_NE(entry.data.i32[i], ANDROID_COLOR_CORRECTION_MODE);
+                ASSERT_NE(entry.data.i32[i], ANDROID_COLOR_CORRECTION_TRANSFORM);
+                ASSERT_NE(entry.data.i32[i], ANDROID_COLOR_CORRECTION_GAINS);
+            }
+        } else {
+            ADD_FAILURE() << "Get camera availableResultKeys failed!";
+        }
+
+        // Check availableCharacteristicKeys
+        retcode = find_camera_metadata_ro_entry(metadata,
+                ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, &entry);
+        if ((0 == retcode) && (entry.count > 0)) {
+            for (size_t i = 0; i < entry.count; i++) {
+                ASSERT_NE(entry.data.i32[i], ANDROID_SENSOR_REFERENCE_ILLUMINANT1);
+                ASSERT_NE(entry.data.i32[i], ANDROID_SENSOR_REFERENCE_ILLUMINANT2);
+                ASSERT_NE(entry.data.i32[i], ANDROID_SENSOR_CALIBRATION_TRANSFORM1);
+                ASSERT_NE(entry.data.i32[i], ANDROID_SENSOR_CALIBRATION_TRANSFORM2);
+                ASSERT_NE(entry.data.i32[i], ANDROID_SENSOR_COLOR_TRANSFORM1);
+                ASSERT_NE(entry.data.i32[i], ANDROID_SENSOR_COLOR_TRANSFORM2);
+                ASSERT_NE(entry.data.i32[i], ANDROID_SENSOR_FORWARD_MATRIX1);
+                ASSERT_NE(entry.data.i32[i], ANDROID_SENSOR_FORWARD_MATRIX2);
+            }
+        } else {
+            ADD_FAILURE() << "Get camera availableResultKeys failed!";
+        }
+
+        // Check blackLevelPattern
+        retcode = find_camera_metadata_ro_entry(metadata,
+                ANDROID_SENSOR_BLACK_LEVEL_PATTERN, &entry);
+        if ((0 == retcode) && (entry.count > 0)) {
+            ASSERT_EQ(entry.count, 4);
+            for (size_t i = 1; i < entry.count; i++) {
+                ASSERT_EQ(entry.data.i32[i], entry.data.i32[0]);
+            }
+        }
+    }
+}
+
+void CameraHidlTest::verifyMonochromeCameraResult(
+        const ::android::hardware::camera::common::V1_0::helper::CameraMetadata& metadata) {
+    camera_metadata_ro_entry entry;
+
+    // Check tags that are not applicable for monochrome camera
+    ASSERT_FALSE(metadata.exists(ANDROID_SENSOR_GREEN_SPLIT));
+    ASSERT_FALSE(metadata.exists(ANDROID_SENSOR_NEUTRAL_COLOR_POINT));
+    ASSERT_FALSE(metadata.exists(ANDROID_COLOR_CORRECTION_MODE));
+    ASSERT_FALSE(metadata.exists(ANDROID_COLOR_CORRECTION_TRANSFORM));
+    ASSERT_FALSE(metadata.exists(ANDROID_COLOR_CORRECTION_GAINS));
+
+    // Check dynamicBlackLevel
+    entry = metadata.find(ANDROID_SENSOR_DYNAMIC_BLACK_LEVEL);
+    if (entry.count > 0) {
+        ASSERT_EQ(entry.count, 4);
+        for (size_t i = 1; i < entry.count; i++) {
+            ASSERT_FLOAT_EQ(entry.data.f[i], entry.data.f[0]);
+        }
+    }
+
+    // Check noiseProfile
+    entry = metadata.find(ANDROID_SENSOR_NOISE_PROFILE);
+    if (entry.count > 0) {
+        ASSERT_EQ(entry.count, 2);
+    }
+
+    // Check lensShadingMap
+    entry = metadata.find(ANDROID_STATISTICS_LENS_SHADING_MAP);
+    if (entry.count > 0) {
+        ASSERT_EQ(entry.count % 4, 0);
+        for (size_t i = 0; i < entry.count/4; i++) {
+            ASSERT_FLOAT_EQ(entry.data.f[i*4+1], entry.data.f[i*4]);
+            ASSERT_FLOAT_EQ(entry.data.f[i*4+2], entry.data.f[i*4]);
+            ASSERT_FLOAT_EQ(entry.data.f[i*4+3], entry.data.f[i*4]);
+        }
+    }
+
+    // Check tonemapCurve
+    camera_metadata_ro_entry curveRed = metadata.find(ANDROID_TONEMAP_CURVE_RED);
+    camera_metadata_ro_entry curveGreen = metadata.find(ANDROID_TONEMAP_CURVE_GREEN);
+    camera_metadata_ro_entry curveBlue = metadata.find(ANDROID_TONEMAP_CURVE_BLUE);
+    if (curveRed.count > 0 && curveGreen.count > 0 && curveBlue.count > 0) {
+        ASSERT_EQ(curveRed.count, curveGreen.count);
+        ASSERT_EQ(curveRed.count, curveBlue.count);
+        for (size_t i = 0; i < curveRed.count; i++) {
+            ASSERT_FLOAT_EQ(curveGreen.data.f[i], curveRed.data.f[i]);
+            ASSERT_FLOAT_EQ(curveBlue.data.f[i], curveRed.data.f[i]);
+        }
+    }
+}
+
+void CameraHidlTest::verifyBuffersReturned(
+        sp<device::V3_2::ICameraDeviceSession> session,
+        int deviceVersion, int32_t streamId,
+        sp<DeviceCb> cb, uint32_t streamConfigCounter) {
+    sp<device::V3_3::ICameraDeviceSession> session3_3;
+    sp<device::V3_4::ICameraDeviceSession> session3_4;
+    sp<device::V3_5::ICameraDeviceSession> session3_5;
+    castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5);
+    ASSERT_NE(nullptr, session3_5.get());
+
+    hidl_vec<int32_t> streamIds(1);
+    streamIds[0] = streamId;
+    session3_5->signalStreamFlush(streamIds, /*streamConfigCounter*/streamConfigCounter);
+    cb->waitForBuffersReturned();
+}
+
+void CameraHidlTest::verifyBuffersReturned(
+        sp<device::V3_4::ICameraDeviceSession> session3_4,
+        hidl_vec<int32_t> streamIds, sp<DeviceCb> cb, uint32_t streamConfigCounter) {
+    auto castResult = device::V3_5::ICameraDeviceSession::castFrom(session3_4);
+    ASSERT_TRUE(castResult.isOk());
+    sp<device::V3_5::ICameraDeviceSession> session3_5 = castResult;
+    ASSERT_NE(nullptr, session3_5.get());
+
+    session3_5->signalStreamFlush(streamIds, /*streamConfigCounter*/streamConfigCounter);
+    cb->waitForBuffersReturned();
+}
+
 // Open a device session with empty callbacks and return static metadata.
-void CameraHidlTest::openEmptyDeviceSession(const std::string &name,
-        sp<ICameraProvider> provider,
-        sp<ICameraDeviceSession> *session /*out*/,
-        camera_metadata_t **staticMeta /*out*/) {
+void CameraHidlTest::openEmptyDeviceSession(const std::string &name, sp<ICameraProvider> provider,
+        sp<ICameraDeviceSession> *session /*out*/, camera_metadata_t **staticMeta /*out*/,
+        ::android::sp<ICameraDevice> *cameraDevice /*out*/) {
     ASSERT_NE(nullptr, session);
     ASSERT_NE(nullptr, staticMeta);
 
@@ -4795,6 +5615,9 @@
             device3_x = device;
         });
     ASSERT_TRUE(ret.isOk());
+    if (cameraDevice != nullptr) {
+        *cameraDevice = device3_x;
+    }
 
     sp<EmptyDeviceCb> cb = new EmptyDeviceCb();
     ret = device3_x->open(cb, [&](auto status, const auto& newSession) {
diff --git a/cas/1.0/default/Android.bp b/cas/1.0/default/Android.bp
index 544162b..debb3e5 100644
--- a/cas/1.0/default/Android.bp
+++ b/cas/1.0/default/Android.bp
@@ -1,5 +1,5 @@
-cc_binary {
-    name: "android.hardware.cas@1.0-service",
+cc_defaults {
+    name: "cas_service_defaults",
     defaults: ["hidl_defaults"],
     vendor: true,
     relative_install_path: "hw",
@@ -13,7 +13,6 @@
     ],
 
     compile_multilib: "32",
-    init_rc: ["android.hardware.cas@1.0-service.rc"],
 
     shared_libs: [
       "android.hardware.cas@1.0",
@@ -31,3 +30,19 @@
       "media_plugin_headers",
     ],
 }
+
+cc_binary {
+    name: "android.hardware.cas@1.0-service",
+    vintf_fragments: ["android.hardware.cas@1.0-service.xml"],
+    defaults: ["cas_service_defaults"],
+    init_rc: ["android.hardware.cas@1.0-service.rc"],
+}
+
+cc_binary {
+    name: "android.hardware.cas@1.0-service-lazy",
+    vintf_fragments: ["android.hardware.cas@1.0-service-lazy.xml"],
+    overrides: ["android.hardware.cas@1.0-service"],
+    defaults: ["cas_service_defaults"],
+    init_rc: ["android.hardware.cas@1.0-service-lazy.rc"],
+    cflags: ["-DLAZY_SERVICE"],
+}
diff --git a/cas/1.0/default/android.hardware.cas@1.0-service-lazy.rc b/cas/1.0/default/android.hardware.cas@1.0-service-lazy.rc
new file mode 100644
index 0000000..735cfbc
--- /dev/null
+++ b/cas/1.0/default/android.hardware.cas@1.0-service-lazy.rc
@@ -0,0 +1,9 @@
+service vendor.cas-hal-1-0 /vendor/bin/hw/android.hardware.cas@1.0-service
+    interface android.hardware.cas@1.0::IMediaCasService default
+    oneshot
+    disabled
+    class hal
+    user media
+    group mediadrm drmrpc
+    ioprio rt 4
+    writepid /dev/cpuset/foreground/tasks
diff --git a/cas/1.0/default/android.hardware.cas@1.0-service-lazy.xml b/cas/1.0/default/android.hardware.cas@1.0-service-lazy.xml
new file mode 100644
index 0000000..9b55370
--- /dev/null
+++ b/cas/1.0/default/android.hardware.cas@1.0-service-lazy.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="device">
+    <hal format="hidl">
+        <name>android.hardware.cas</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IMediaCasService</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+</manifest>
diff --git a/cas/1.0/default/android.hardware.cas@1.0-service.xml b/cas/1.0/default/android.hardware.cas@1.0-service.xml
new file mode 100644
index 0000000..9b55370
--- /dev/null
+++ b/cas/1.0/default/android.hardware.cas@1.0-service.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="device">
+    <hal format="hidl">
+        <name>android.hardware.cas</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IMediaCasService</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+</manifest>
diff --git a/cas/1.0/default/service.cpp b/cas/1.0/default/service.cpp
index 04a8ad9..2e6e55d 100644
--- a/cas/1.0/default/service.cpp
+++ b/cas/1.0/default/service.cpp
@@ -15,7 +15,11 @@
  */
 
 //#define LOG_NDEBUG 0
+#ifdef LAZY_SERVICE
+#define LOG_TAG "android.hardware.cas@1.0-service-lazy"
+#else
 #define LOG_TAG "android.hardware.cas@1.0-service"
+#endif
 
 #include <binder/ProcessState.h>
 #include <hidl/HidlTransportSupport.h>
@@ -25,24 +29,30 @@
 
 using android::hardware::configureRpcThreadpool;
 using android::hardware::joinRpcThreadpool;
-using android::hardware::cas::V1_0::implementation::MediaCasService;
+using android::hardware::LazyServiceRegistrar;
 using android::hardware::cas::V1_0::IMediaCasService;
+using android::hardware::cas::V1_0::implementation::MediaCasService;
+
+#ifdef LAZY_SERVICE
+const bool kLazyService = true;
+#else
+const bool kLazyService = false;
+#endif
 
 int main() {
-    ALOGD("android.hardware.cas@1.0-service starting...");
-
-    // The CAS HAL may communicate to other vendor components via
-    // /dev/vndbinder
-    android::ProcessState::initWithDriver("/dev/vndbinder");
-
     configureRpcThreadpool(8, true /* callerWillJoin */);
 
     // Setup hwbinder service
     android::sp<IMediaCasService> service = new MediaCasService();
-    android::status_t status = service->registerAsService();
-    LOG_ALWAYS_FATAL_IF(
-            status != android::OK,
-            "Error while registering cas service: %d", status);
+    android::status_t status;
+    if (kLazyService) {
+        auto serviceRegistrar = std::make_shared<LazyServiceRegistrar>();
+        status = serviceRegistrar->registerServiceWithCallback(service);
+    } else {
+        status = service->registerAsService();
+    }
+    LOG_ALWAYS_FATAL_IF(status != android::OK, "Error while registering cas service: %d", status);
+
     joinRpcThreadpool();
     return 0;
 }
diff --git a/cas/1.0/vts/functional/Android.bp b/cas/1.0/vts/functional/Android.bp
index 0db9bb0..622baa5 100644
--- a/cas/1.0/vts/functional/Android.bp
+++ b/cas/1.0/vts/functional/Android.bp
@@ -29,5 +29,6 @@
     shared_libs: [
         "libbinder",
     ],
+    test_suites: ["general-tests"],
 }
 
diff --git a/compatibility_matrices/Android.bp b/compatibility_matrices/Android.bp
index 49674e3..b88d88f 100644
--- a/compatibility_matrices/Android.bp
+++ b/compatibility_matrices/Android.bp
@@ -73,5 +73,6 @@
         "kernel_config_current_4.4",
         "kernel_config_current_4.9",
         "kernel_config_current_4.14",
+        "kernel_config_current_4.19",
     ]
 }
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index e117a98..ceb53be 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -145,7 +145,7 @@
     </hal>
     <hal format="hidl" optional="true">
         <name>android.hardware.drm</name>
-        <version>1.0</version>
+        <version>1.0-1</version>
         <interface>
             <name>ICryptoFactory</name>
             <regex-instance>.*</regex-instance>
@@ -157,7 +157,7 @@
     </hal>
     <hal format="hidl" optional="false">
         <name>android.hardware.drm</name>
-        <version>1.1</version>
+        <version>1.2</version>
         <interface>
             <name>ICryptoFactory</name>
             <regex-instance>.*</regex-instance>
@@ -186,6 +186,7 @@
     <hal format="hidl" optional="true">
         <name>android.hardware.gnss</name>
         <version>1.0-1</version>
+        <version>2.0</version>
         <interface>
             <name>IGnss</name>
             <instance>default</instance>
diff --git a/configstore/1.0/vts/functional/Android.bp b/configstore/1.0/vts/functional/Android.bp
index 1b8a591..008b59d 100644
--- a/configstore/1.0/vts/functional/Android.bp
+++ b/configstore/1.0/vts/functional/Android.bp
@@ -19,5 +19,6 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalConfigstoreV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.configstore@1.0"],
+    test_suites: ["general-tests"],
 }
 
diff --git a/confirmationui/1.0/vts/functional/Android.bp b/confirmationui/1.0/vts/functional/Android.bp
index 823e035..d19d702 100644
--- a/confirmationui/1.0/vts/functional/Android.bp
+++ b/confirmationui/1.0/vts/functional/Android.bp
@@ -27,4 +27,5 @@
         "libcn-cbor",
         "android.hardware.confirmationui-support-lib",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/confirmationui/support/Android.bp b/confirmationui/support/Android.bp
index 62156b3..e215baa 100644
--- a/confirmationui/support/Android.bp
+++ b/confirmationui/support/Android.bp
@@ -46,6 +46,7 @@
         "android.hardware.keymaster@4.0",
         "libhidlbase",
     ],
+    test_suites: ["general-tests"],
     clang: true,
     cflags: [ "-O0" ],
 }
diff --git a/contexthub/1.0/vts/functional/Android.bp b/contexthub/1.0/vts/functional/Android.bp
index 7c6e8c7..aef0340 100644
--- a/contexthub/1.0/vts/functional/Android.bp
+++ b/contexthub/1.0/vts/functional/Android.bp
@@ -19,5 +19,6 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalContexthubV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.contexthub@1.0"],
+    test_suites: ["general-tests"],
 }
 
diff --git a/current.txt b/current.txt
index 8b10648..e19fb63 100644
--- a/current.txt
+++ b/current.txt
@@ -388,8 +388,10 @@
 2a55e224aa9bc62c0387cd85ad3c97e33f0c33a4e1489cbae86b2523e6f9df35 android.hardware.camera.device@3.2::ICameraDevice
 f61b616732d8f374e030f90575d7eba3ecc99d209a05b945949ba892bcb81e1d android.hardware.camera.device@3.2::ICameraDeviceSession
 684702a60deef03a1e8093961dc0a18c555c857ad5a77ba7340b0635ae01eb70 android.hardware.camera.device@3.4::ICameraDeviceSession
+291638a1b6d4e63283e9e722ab5049d9351717ffa2b66162124f84d1aa7c2835 android.hardware.camera.metadata@3.2::types
 dd2436f251a90f3e5e7ed773b1aeae21e381b00ae26b10ebe3a1001c894e5980 android.hardware.camera.metadata@3.3::types
 da33234403ff5d60f3473711917b9948e6484a4260b5247acdafb111193a9de2 android.hardware.configstore@1.0::ISurfaceFlingerConfigs
+21165b8e30c4b2d52980e4728f661420adc16e38bbe73476c06b2085be908f4c android.hardware.gnss@1.0::IGnssCallback
 d702fb01dc2a0733aa820b7eb65435ee3334f75632ef880bafd2fb8803a20a58 android.hardware.gnss@1.0::IGnssMeasurementCallback
 b7ecf29927055ec422ec44bf776223f07d79ad9f92ccf9becf167e62c2607e7a android.hardware.keymaster@4.0::IKeymasterDevice
 574e8f1499436fb4075894dcae0b36682427956ecb114f17f1fe22d116a83c6b android.hardware.neuralnetworks@1.0::IPreparedModel
diff --git a/drm/1.0/vts/functional/Android.bp b/drm/1.0/vts/functional/Android.bp
index 57678fb..d6ebfdd 100644
--- a/drm/1.0/vts/functional/Android.bp
+++ b/drm/1.0/vts/functional/Android.bp
@@ -32,4 +32,5 @@
         "libssl",
         "libcrypto",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/drm/1.1/vts/functional/Android.bp b/drm/1.1/vts/functional/Android.bp
index 782f283..1090b69 100644
--- a/drm/1.1/vts/functional/Android.bp
+++ b/drm/1.1/vts/functional/Android.bp
@@ -31,4 +31,5 @@
         "libssl",
         "libcrypto",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/drm/1.2/Android.bp b/drm/1.2/Android.bp
new file mode 100644
index 0000000..66a1bd8
--- /dev/null
+++ b/drm/1.2/Android.bp
@@ -0,0 +1,26 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.drm@1.2",
+    root: "android.hardware",
+    vndk: {
+        enabled: true,
+    },
+    srcs: [
+        "types.hal",
+        "ICryptoFactory.hal",
+        "IDrmFactory.hal",
+        "IDrmPlugin.hal",
+    ],
+    interfaces: [
+        "android.hardware.drm@1.0",
+        "android.hardware.drm@1.1",
+        "android.hidl.base@1.0",
+    ],
+    types: [
+        "KeySetId",
+        "OfflineLicenseState",
+    ],
+    gen_java: false,
+}
+
diff --git a/drm/1.2/ICryptoFactory.hal b/drm/1.2/ICryptoFactory.hal
new file mode 100644
index 0000000..c4a9b4b
--- /dev/null
+++ b/drm/1.2/ICryptoFactory.hal
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.drm@1.2;
+
+import @1.1::ICryptoFactory;
+
+/**
+ * ICryptoFactory is the main entry point for interacting with a vendor's
+ * crypto HAL to create crypto plugins. Crypto plugins create crypto sessions
+ * which are used by a codec to decrypt protected video content.
+ *
+ * The 1.2 factory must always create 1.2 ICryptoPlugin interfaces, which are
+ * returned via the 1.0 createPlugin method.
+ *
+ * To use 1.2 features the caller must cast the returned interface to a
+ * 1.2 HAL, using V1_2::IDrmPlugin::castFrom().
+ *
+ * The ICryptoFactory hal is required because all top-level interfaces
+ * have to be updated in a minor uprev.
+ */
+interface ICryptoFactory extends @1.1::ICryptoFactory {
+};
diff --git a/drm/1.2/IDrmFactory.hal b/drm/1.2/IDrmFactory.hal
new file mode 100644
index 0000000..c94e4bb
--- /dev/null
+++ b/drm/1.2/IDrmFactory.hal
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.drm@1.2;
+
+import @1.1::IDrmFactory;
+import @1.1::IDrmPlugin;
+
+/**
+ * IDrmFactory is the main entry point for interacting with a vendor's
+ * drm HAL to create drm plugin instances. A drm plugin instance
+ * creates drm sessions which are used to obtain keys for a crypto
+ * session so it can decrypt protected video content.
+ *
+ * The 1.2 factory must always create 1.2 IDrmPlugin interfaces, which are
+ * returned via the 1.0 createPlugin method.
+ *
+ * To use 1.2 features the caller must cast the returned interface to a
+ * 1.2 HAL, using V1_2::IDrmPlugin::castFrom().
+ *
+ * The IDrmFactory hal is required because all top-level interfaces
+ * have to be updated in a minor uprev.
+ */
+
+interface IDrmFactory extends @1.1::IDrmFactory {
+};
diff --git a/drm/1.2/IDrmPlugin.hal b/drm/1.2/IDrmPlugin.hal
new file mode 100644
index 0000000..88338d6
--- /dev/null
+++ b/drm/1.2/IDrmPlugin.hal
@@ -0,0 +1,94 @@
+/**
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.drm@1.2;
+
+import @1.1::IDrmPlugin;
+import @1.0::Status;
+
+/**
+ * IDrmPlugin is used to interact with a specific drm plugin that was created by
+ * IDrm::createPlugin. A drm plugin provides methods for obtaining drm keys that
+ * may be used by a codec to decrypt protected video content.
+ */
+interface IDrmPlugin extends @1.1::IDrmPlugin {
+
+    /**
+     * The keys in an offline license allow protected content to be
+     * played even if the device is not connected to a network.
+     * Offline licenses are stored on the device after a key
+     * request/response exchange when the key request KeyType is
+     * OFFLINE. Normally each app is responsible for keeping track of
+     * the KeySetIds it has created. In some situations however, it
+     * may be necessary to request the list of stored offline license
+     * KeySetIds. If an app loses the KeySetId for any stored licenses
+     * that it created, for example, it must be able to recover the
+     * stored KeySetIds so those licenses can be removed when they
+     * expire or when the app is uninstalled.
+     * <p>
+     * This method returns a list of the KeySetIds for all offline
+     * licenses. The offline license KeySetId may be used to query
+     * the status of an offline license or remove it.
+     *
+     * @return status the status of the call. May be OK or
+     *     ERROR_DRM_INVALID_STATE if the HAL is in a state where the
+     *     KeySetIds can't be returned.
+     * @return a list of offline license keySetIds. If there are no offline
+     *     licenses, the list must be empty and OK must be returned as the
+     *     status.
+     */
+    getOfflineLicenseKeySetIds() generates (Status status, vec<KeySetId> keySetIds);
+
+    /**
+     * Normally offline licenses are released using a key
+     * request/response exchange using getKeyRequest where the KeyType
+     * is RELEASE, followed by provideKeyResponse. This allows the
+     * server to cryptographically confirm that the license has been
+     * removed and then adjust the count of offline licenses allocated
+     * to the device.
+     * <p>
+     * In some exceptional situations it may be necessary to directly
+     * remove offline licenses without notifying the server, which may
+     * be performed using this method.
+     *
+     * @param keySetId the id of the offline license to remove
+     * @return status the status of the call. May be one of OK on
+     *     success, BAD_VALUE if the license is not found or
+     *     ERROR_DRM_INVALID_STATE if the HAL is in a state where the
+     *     KeySetIds can't be returned.
+     */
+    removeOfflineLicense(KeySetId keySetId) generates (Status status);
+
+    /**
+     * Request the state of an offline license. An offline license may
+     * be usable or inactive. The keys in a usable offline license are
+     * available for decryption. When the offline license state is
+     * inactive, the keys have been marked for release using
+     * getKeyRequest with KeyType RELEASE but the key response has not
+     * been received. The keys in an inactive offline license are not
+     * usable for decryption.
+     *
+     * @param keySetId the id of the offline license
+     * @return status the status of the call. May be one of OK on
+     *     success, BAD_VALUE if the license is not found or
+     *     ERROR_DRM_INVALID_STATE if the HAL is in a state where the
+     *     offline license state can't be queried.
+     * @return the offline license state, one of USABLE or INACTIVE.
+     *     If the return status is not OK then state must be set to
+     *     UNKNOWN.
+     */
+    getOfflineLicenseState(KeySetId keySetId) generates (Status status,
+            OfflineLicenseState state);
+};
diff --git a/drm/1.2/types.hal b/drm/1.2/types.hal
new file mode 100644
index 0000000..8770c79
--- /dev/null
+++ b/drm/1.2/types.hal
@@ -0,0 +1,45 @@
+/**
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.drm@1.2;
+
+enum OfflineLicenseState : uint32_t {
+    /**
+     * Offline license state is unknown
+     */
+    UNKNOWN,
+
+    /**
+     * Offline license state is usable, the keys may be used for decryption.
+     */
+    USABLE,
+
+    /**
+     * Offline license state is inactive, the keys have been marked for
+     * release using {@link #getKeyRequest} with KEY_TYPE_RELEASE but the
+     * key response has not been received.
+     */
+    INACTIVE
+};
+
+/**
+ * KeySetId is an identifier that references a set of keys in an
+ * offline license. The keySetId is created by the HAL implementation
+ * and returned from provideKeyResponse and getOfflineLicenseIds. The
+ * framework passes KeySetId back to the HAL when referring to the key
+ * set in methods that take a KeySetId as an input parameter.
+ */
+typedef vec<uint8_t> KeySetId;
diff --git a/dumpstate/1.0/vts/functional/Android.bp b/dumpstate/1.0/vts/functional/Android.bp
index 1ab530f..fc64d05 100644
--- a/dumpstate/1.0/vts/functional/Android.bp
+++ b/dumpstate/1.0/vts/functional/Android.bp
@@ -18,4 +18,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalDumpstateV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.dumpstate@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/gatekeeper/1.0/vts/functional/Android.bp b/gatekeeper/1.0/vts/functional/Android.bp
index aa1da7b..f55e5d2 100644
--- a/gatekeeper/1.0/vts/functional/Android.bp
+++ b/gatekeeper/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalGatekeeperV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.gatekeeper@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/gnss/1.0/IGnssCallback.hal b/gnss/1.0/IGnssCallback.hal
index 7fb38c5..d62676f 100644
--- a/gnss/1.0/IGnssCallback.hal
+++ b/gnss/1.0/IGnssCallback.hal
@@ -115,9 +115,9 @@
         /**
          * 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
-         * is the primary common use central frequency, e.g. L1 = 1575.45 MHz
-         * for GPS.
+         * 1176.45 MHz, varying GLO channels, etc. If the field is zero, it is
+         * the primary common use central frequency, e.g. L1 = 1575.45 MHz for
+         * GPS.
          *
          * For an L1, L5 receiver tracking a satellite on L1 and L5 at the same
          * time, two GnssSvInfo structs must be reported for this same
@@ -125,8 +125,7 @@
          * to L1 must be filled, and in the other all of the values related to
          * L5 must be filled.
          *
-         * If the data is available, gnssClockFlags must contain
-         * HAS_CARRIER_FREQUENCY.
+         * If the data is available, svFlag must contain HAS_CARRIER_FREQUENCY.
          */
         float carrierFrequencyHz;
 
diff --git a/gnss/1.0/vts/functional/Android.bp b/gnss/1.0/vts/functional/Android.bp
index d7713db..505cb41 100644
--- a/gnss/1.0/vts/functional/Android.bp
+++ b/gnss/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalGnssV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.gnss@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/gnss/1.1/vts/functional/Android.bp b/gnss/1.1/vts/functional/Android.bp
index 67ef486..9892eca 100644
--- a/gnss/1.1/vts/functional/Android.bp
+++ b/gnss/1.1/vts/functional/Android.bp
@@ -26,4 +26,5 @@
         "android.hardware.gnss@1.0",
         "android.hardware.gnss@1.1",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/gnss/2.0/Android.bp b/gnss/2.0/Android.bp
new file mode 100644
index 0000000..6a06bf4
--- /dev/null
+++ b/gnss/2.0/Android.bp
@@ -0,0 +1,24 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.gnss@2.0",
+    root: "android.hardware",
+    vndk: {
+        enabled: true,
+    },
+    srcs: [
+        "IGnss.hal",
+        "IGnssCallback.hal",
+        "IGnssMeasurement.hal",
+        "IGnssMeasurementCallback.hal",
+    ],
+    interfaces: [
+        "android.hardware.gnss.measurement_corrections@1.0",
+        "android.hardware.gnss@1.0",
+        "android.hardware.gnss@1.1",
+        "android.hidl.base@1.0",
+    ],
+    gen_java: true,
+    gen_java_constants: true,
+}
+
diff --git a/gnss/2.0/IGnss.hal b/gnss/2.0/IGnss.hal
new file mode 100644
index 0000000..55621e5
--- /dev/null
+++ b/gnss/2.0/IGnss.hal
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.gnss@2.0;
+
+import android.hardware.gnss.measurement_corrections@1.0::IMeasurementCorrections;
+import @1.1::IGnss;
+
+import IGnssCallback;
+import IGnssMeasurement;
+
+/** Represents the standard GNSS (Global Navigation Satellite System) interface. */
+interface IGnss extends @1.1::IGnss {
+     /**
+     * Opens the interface and provides the callback routines to the implementation of this
+     * interface.
+     *
+     * @param callback Callback interface for IGnss.
+     *
+     * @return success Returns true on success.
+     */
+    setCallback_2_0(IGnssCallback callback) generates (bool success);
+
+    /**
+     * This method returns the IGnssMeasurement interface.
+     *
+     * Exactly one of getExtensionGnssMeasurement_1_1() and getExtensionGnssMeasurement_2_0() must
+     * return a non-null handle, and the other method must return nullptr.
+     *
+     * @return gnssMeasurementIface Handle to the IGnssMeasurement interface.
+     */
+    getExtensionGnssMeasurement_2_0() generates (IGnssMeasurement gnssMeasurementIface);
+
+    /**
+     * This method returns the IMeasurementCorrections interface.
+     *
+     * @return measurementCorrectionsIface Handle to the IMeasurementCorrections interface.
+     */
+     getExtensionMeasurementCorrections()
+            generates (IMeasurementCorrections measurementCorrectionsIface);
+};
\ No newline at end of file
diff --git a/gnss/2.0/IGnssCallback.hal b/gnss/2.0/IGnssCallback.hal
new file mode 100644
index 0000000..1cdd2c0
--- /dev/null
+++ b/gnss/2.0/IGnssCallback.hal
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.gnss@2.0;
+
+import @1.0::IGnssCallback;
+import @1.1::IGnssCallback;
+
+/**
+ * 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 extends @1.1::IGnssCallback {
+
+    /** Flags for the gnssSetCapabilities callback. */
+    @export(name="", value_prefix="GPS_CAPABILITY_")
+    enum Capabilities : @1.0::IGnssCallback.Capabilities {
+        /** GNSS supports line-of-sight satellite identification measurement Corrections */
+        MEASUREMENT_CORRECTIONS_LOS_SATS                        = 1 << 8,
+        /** GNSS supports per satellite excess-path-length measurement Corrections */
+        MEASUREMENT_CORRECTIONS_EXCESS_PATH_LENGTH              = 1 << 10,
+        /** GNSS supports reflecting planes measurement Corrections */
+        MEASUREMENT_CORRECTIONS_REFLECTING_PLANE                = 1 << 20
+    };
+
+    /**
+     * Callback to inform framework of the GNSS engine's capabilities.
+     *
+     * @param capabilities Capability parameter is a bit field of the Capabilities enum.
+     */
+    gnssSetCapabilitiesCb_2_0(bitfield<Capabilities> capabilities);
+
+};
\ No newline at end of file
diff --git a/gnss/2.0/IGnssMeasurement.hal b/gnss/2.0/IGnssMeasurement.hal
new file mode 100644
index 0000000..108f3d2
--- /dev/null
+++ b/gnss/2.0/IGnssMeasurement.hal
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.gnss@2.0;
+
+import @1.0::IGnssMeasurement;
+import @1.1::IGnssMeasurement;
+import IGnssMeasurementCallback;
+
+/**
+ * Extended interface for GNSS Measurements support.
+ */
+interface IGnssMeasurement extends @1.1::IGnssMeasurement {
+
+    /**
+     * Initializes the interface and registers the callback routines with the HAL. After a
+     * successful call to 'setCallback_2_0' the HAL must begin to provide updates at an average
+     * output rate of 1Hz (occasional intra-measurement time offsets in the range from 0-2000msec
+     * can be tolerated.)
+     *
+     * @param callback Handle to GnssMeasurement callback interface.
+     * @param enableFullTracking If true, GNSS chipset must switch off duty cycling. In such mode
+     *     no clock discontinuities are expected and, when supported, carrier phase should be
+     *     continuous in good signal conditions. All non-blacklisted, healthy constellations,
+     *     satellites and frequency bands that the chipset supports must be reported in this mode.
+     *     The GNSS chipset is allowed to consume more power in this mode. If false, API must behave
+     *     as in HAL V1_0, optimizing power via duty cycling, constellations and frequency limits,
+     *     etc.
+     *
+     * @return initRet Returns SUCCESS if successful. Returns ERROR_ALREADY_INIT if a callback has
+     *     already been registered without a corresponding call to 'close'. Returns ERROR_GENERIC
+     *     for any other error. The HAL must not generate any other updates upon returning this
+     *     error code.
+     */
+    setCallback_2_0(IGnssMeasurementCallback callback, bool enableFullTracking)
+         generates (GnssMeasurementStatus initRet);
+
+};
diff --git a/gnss/2.0/IGnssMeasurementCallback.hal b/gnss/2.0/IGnssMeasurementCallback.hal
new file mode 100644
index 0000000..226934e
--- /dev/null
+++ b/gnss/2.0/IGnssMeasurementCallback.hal
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.gnss@2.0;
+
+import @1.0::IGnssMeasurementCallback;
+import @1.1::IGnssMeasurementCallback;
+
+/** The callback interface to report measurements from the HAL. */
+interface IGnssMeasurementCallback extends @1.1::IGnssMeasurementCallback {
+    /**
+     * Enumeration of available values for the GNSS Measurement's code type. Similar to the
+     * Attribute field described in Rinex 3.03, e.g., in Tables 4-10, and Table A2 at the Rinex 3.03
+     * Update 1 Document.
+     */
+    enum GnssMeasurementCodeType : uint8_t {
+        /** GALILEO E1A, GALILEO E6A, IRNSS L5A, IRNSS SA. */
+        CODE_TYPE_A = 0,
+
+        /** GALILEO E1B, GALILEO E6B, IRNSS L5B, IRNSS SB. */
+        CODE_TYPE_B = 1,
+
+        /**
+         *  GPS L1 C/A,  GPS L2 C/A, GLONASS G1 C/A, GLONASS G2 C/A, GALILEO E1C, GALILEO E6C, SBAS
+         *  L1 C/A, QZSS L1 C/A, IRNSS L5C.
+         */
+        CODE_TYPE_C = 2,
+
+        /**
+         * GPS L5 I, GLONASS G3 I, GALILEO E5a I, GALILEO E5b I, GALILEO E5a+b I, SBAS L5 I, QZSS L5
+         * I, BDS B1 I, BDS B2 I, BDS B3 I.
+         */
+        CODE_TYPE_I = 3,
+
+        /** GPS L1C (P), GPS L2C (L), QZSS L1C (P), QZSS L2C (L), LEX(6) L. */
+        CODE_TYPE_L = 4,
+
+        /** GPS L1M, GPS L2M. */
+        CODE_TYPE_M = 5,
+
+        /** GPS L1P, GPS L2P, GLONASS G1P, GLONASS G2P. */
+        CODE_TYPE_P = 6,
+
+        /**
+         * GPS L5 Q, GLONASS G3 Q, GALILEO E5a Q, GALILEO E5b Q, GALILEO E5a+b Q, SBAS L5 Q, QZSS L5
+         * Q, BDS B1 Q, BDS B2 Q, BDS B3 Q.
+         */
+        CODE_TYPE_Q = 7,
+
+        /** GPS L1C (D), GPS L2C (M), QZSS L1C (D), QZSS L2C (M), LEX(6) S. */
+        CODE_TYPE_S = 8,
+
+        /** GPS L1 Z-tracking, GPS L2 Z-tracking. */
+        CODE_TYPE_W = 9,
+
+        /**
+         * GPS L1C (D+P), GPS L2C (M+L), GPS L5 (I+Q), GLONASS G3 (I+Q), GALILEO E1 (B+C), GALILEO
+         * E5a (I+Q), GALILEO E5b (I+Q), GALILEO E5a+b(I+Q), GALILEO E6 (B+C), SBAS L5 (I+Q), QZSS
+         * L1C (D+P), QZSS L2C (M+L), QZSS L5 (I+Q), LEX(6) (S+L), BDS B1 (I+Q), BDS B2 (I+Q), BDS
+         * B3 (I+Q), IRNSS L5 (B+C).
+         */
+        CODE_TYPE_X = 10,
+
+        /** GPS L1Y, GPS L2Y. */
+        CODE_TYPE_Y = 11,
+
+        /** GALILEO E1 (A+B+C), GALILEO E6 (A+B+C), QZSS L1-SAIF. */
+        CODE_TYPE_Z = 12,
+
+        /** GPS L1 codeless, GPS L2 codeless. */
+        CODE_TYPE_CODELESS = 13
+    };
+
+    /**
+     * Extends a GNSS Measurement, adding a GnssMeasurementCodeType.
+     */
+    struct GnssMeasurement {
+        /**
+         * GNSS measurement information for a single satellite and frequency, as in the 1.1
+         * version of the HAL with further clarification of the value reported in the
+         * accumulatedDeltaRangeM field, i.e., the alignment of the phase measurement will not be
+         * adjusted by the receiver so the in-phase and quadrature phase components will have a
+         * quarter cycle offset as they do when transmitted from the satellites. If the measurement
+         * is from a combination of the in-phase and quadrature phase components, then the alignment
+         * of the phase measurement will be aligned to the in-phase component.
+         */
+        @1.1::IGnssMeasurementCallback.GnssMeasurement v1_1;
+
+        /**
+         * The type of code that is currently being tracked in the GNSS measurement.
+         *
+         * For high precision applications the type of code being tracked needs to be considered
+         * in-order to properly apply code specific corrections to the psuedorange measurements.
+         */
+        GnssMeasurementCodeType codeType;
+    };
+
+    /**
+     * Complete set of GNSS Measurement data, same as 1.1 with additional enum in measurements.
+     */
+    struct GnssData {
+        /** The full set of satellite measurement observations. */
+        vec<GnssMeasurement> 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.
+     */
+    gnssMeasurementCb_2_0(GnssData data);
+};
diff --git a/gnss/2.0/default/Android.bp b/gnss/2.0/default/Android.bp
new file mode 100644
index 0000000..bec8260
--- /dev/null
+++ b/gnss/2.0/default/Android.bp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+cc_binary {
+    name: "android.hardware.gnss@2.0-service",
+    init_rc: ["android.hardware.gnss@2.0-service.rc"],
+    relative_install_path: "hw",
+    vendor: true,
+    srcs: [
+        "Gnss.cpp",
+        "GnssMeasurement.cpp",
+        "service.cpp"
+    ],
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "libutils",
+        "liblog",
+        "android.hardware.gnss@2.0",
+        "android.hardware.gnss.measurement_corrections@1.0",
+        "android.hardware.gnss@1.0",
+        "android.hardware.gnss@1.1",
+    ],
+}
diff --git a/gnss/2.0/default/Gnss.cpp b/gnss/2.0/default/Gnss.cpp
new file mode 100644
index 0000000..e21fb17
--- /dev/null
+++ b/gnss/2.0/default/Gnss.cpp
@@ -0,0 +1,225 @@
+/*
+ * Copyright (C) 2018 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 "Gnss"
+
+#include "Gnss.h"
+#include <log/log.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V2_0 {
+namespace implementation {
+
+sp<V2_0::IGnssCallback> Gnss::sGnssCallback_2_0 = nullptr;
+sp<V1_1::IGnssCallback> Gnss::sGnssCallback_1_1 = nullptr;
+
+// Methods from V1_0::IGnss follow.
+Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>&) {
+    // TODO implement
+    return bool{};
+}
+
+Return<bool> Gnss::start() {
+    // TODO implement
+    return bool{};
+}
+
+Return<bool> Gnss::stop() {
+    // TODO implement
+    return bool{};
+}
+
+Return<void> Gnss::cleanup() {
+    // TODO implement
+    return Void();
+}
+
+Return<bool> Gnss::injectTime(int64_t, int64_t, int32_t) {
+    // TODO implement
+    return bool{};
+}
+
+Return<bool> Gnss::injectLocation(double, double, float) {
+    // TODO implement
+    return bool{};
+}
+
+Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData) {
+    // TODO implement
+    return Void();
+}
+
+Return<bool> Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode,
+                                   V1_0::IGnss::GnssPositionRecurrence, uint32_t, uint32_t,
+                                   uint32_t) {
+    // TODO implement
+    return bool{};
+}
+
+Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() {
+    // TODO implement
+    return sp<V1_0::IAGnssRil>{};
+}
+
+Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing() {
+    // TODO implement
+    return sp<V1_0::IGnssGeofencing>{};
+}
+
+Return<sp<V1_0::IAGnss>> Gnss::getExtensionAGnss() {
+    // TODO implement
+    return sp<V1_0::IAGnss>{};
+}
+
+Return<sp<V1_0::IGnssNi>> Gnss::getExtensionGnssNi() {
+    // TODO implement
+    return sp<V1_0::IGnssNi>{};
+}
+
+Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() {
+    // TODO implement
+    return sp<V1_0::IGnssMeasurement>{};
+}
+
+Return<sp<V1_0::IGnssNavigationMessage>> Gnss::getExtensionGnssNavigationMessage() {
+    // TODO implement
+    return sp<V1_0::IGnssNavigationMessage>{};
+}
+
+Return<sp<V1_0::IGnssXtra>> Gnss::getExtensionXtra() {
+    // TODO implement
+    return sp<V1_0::IGnssXtra>{};
+}
+
+Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration() {
+    // TODO implement
+    return sp<V1_0::IGnssConfiguration>{};
+}
+
+Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() {
+    // TODO implement
+    return sp<V1_0::IGnssDebug>{};
+}
+
+Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching() {
+    // TODO implement
+    return sp<V1_0::IGnssBatching>{};
+}
+
+// Methods from V1_1::IGnss follow.
+Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
+    ALOGD("Gnss::setCallback_1_1");
+    if (callback == nullptr) {
+        ALOGE("%s: Null callback ignored", __func__);
+        return false;
+    }
+
+    sGnssCallback_1_1 = callback;
+
+    uint32_t capabilities = 0x0;
+    auto ret = sGnssCallback_1_1->gnssSetCapabilitesCb(capabilities);
+    if (!ret.isOk()) {
+        ALOGE("%s: Unable to invoke callback", __func__);
+    }
+
+    V1_1::IGnssCallback::GnssSystemInfo gnssInfo = {.yearOfHw = 2019};
+
+    ret = sGnssCallback_1_1->gnssSetSystemInfoCb(gnssInfo);
+    if (!ret.isOk()) {
+        ALOGE("%s: Unable to invoke callback", __func__);
+    }
+
+    auto gnssName = "Google Mock GNSS Implementation v2.0";
+    ret = sGnssCallback_1_1->gnssNameCb(gnssName);
+    if (!ret.isOk()) {
+        ALOGE("%s: Unable to invoke callback", __func__);
+    }
+
+    return true;
+}
+
+Return<bool> Gnss::setPositionMode_1_1(V1_0::IGnss::GnssPositionMode,
+                                       V1_0::IGnss::GnssPositionRecurrence, uint32_t, uint32_t,
+                                       uint32_t, bool) {
+    // TODO implement
+    return bool{};
+}
+
+Return<sp<V1_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_1_1() {
+    // TODO implement
+    return sp<V1_1::IGnssConfiguration>{};
+}
+
+Return<sp<V1_1::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_1_1() {
+    // TODO implement
+    return sp<V1_1::IGnssMeasurement>{};
+}
+
+Return<bool> Gnss::injectBestLocation(const V1_0::GnssLocation&) {
+    // TODO implement
+    return bool{};
+}
+
+// Methods from V2_0::IGnss follow.
+Return<sp<V2_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_0() {
+    // TODO implement
+    return sp<V2_0::IGnssMeasurement>{};
+}
+
+Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>>
+Gnss::getExtensionMeasurementCorrections() {
+    // TODO implement
+    return sp<measurement_corrections::V1_0::IMeasurementCorrections>{};
+}
+
+Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
+    ALOGD("Gnss::setCallback_2_0");
+    if (callback == nullptr) {
+        ALOGE("%s: Null callback ignored", __func__);
+        return false;
+    }
+
+    sGnssCallback_2_0 = callback;
+
+    uint32_t capabilities = 0x0;
+    auto ret = sGnssCallback_2_0->gnssSetCapabilitesCb(capabilities);
+    if (!ret.isOk()) {
+        ALOGE("%s: Unable to invoke callback", __func__);
+    }
+
+    V1_1::IGnssCallback::GnssSystemInfo gnssInfo = {.yearOfHw = 2019};
+
+    ret = sGnssCallback_2_0->gnssSetSystemInfoCb(gnssInfo);
+    if (!ret.isOk()) {
+        ALOGE("%s: Unable to invoke callback", __func__);
+    }
+
+    auto gnssName = "Google Mock GNSS Implementation v2.0";
+    ret = sGnssCallback_2_0->gnssNameCb(gnssName);
+    if (!ret.isOk()) {
+        ALOGE("%s: Unable to invoke callback", __func__);
+    }
+
+    return true;
+}
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace gnss
+}  // namespace hardware
+}  // namespace android
diff --git a/gnss/2.0/default/Gnss.h b/gnss/2.0/default/Gnss.h
new file mode 100644
index 0000000..7f14513
--- /dev/null
+++ b/gnss/2.0/default/Gnss.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
+#define ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
+
+#include <android/hardware/gnss/2.0/IGnss.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V2_0 {
+namespace implementation {
+
+using ::android::sp;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+
+struct Gnss : public IGnss {
+    // Methods from V1_0::IGnss follow.
+    Return<bool> setCallback(const sp<V1_0::IGnssCallback>& callback) override;
+    Return<bool> start() override;
+    Return<bool> stop() override;
+    Return<void> cleanup() override;
+    Return<bool> injectTime(int64_t timeMs, int64_t timeReferenceMs,
+                            int32_t uncertaintyMs) override;
+    Return<bool> injectLocation(double latitudeDegrees, double longitudeDegrees,
+                                float accuracyMeters) override;
+    Return<void> deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) override;
+    Return<bool> setPositionMode(V1_0::IGnss::GnssPositionMode mode,
+                                 V1_0::IGnss::GnssPositionRecurrence recurrence,
+                                 uint32_t minIntervalMs, uint32_t preferredAccuracyMeters,
+                                 uint32_t preferredTimeMs) override;
+    Return<sp<V1_0::IAGnssRil>> getExtensionAGnssRil() override;
+    Return<sp<V1_0::IGnssGeofencing>> getExtensionGnssGeofencing() override;
+    Return<sp<V1_0::IAGnss>> getExtensionAGnss() override;
+    Return<sp<V1_0::IGnssNi>> getExtensionGnssNi() override;
+    Return<sp<V1_0::IGnssMeasurement>> getExtensionGnssMeasurement() override;
+    Return<sp<V1_0::IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override;
+    Return<sp<V1_0::IGnssXtra>> getExtensionXtra() override;
+    Return<sp<V1_0::IGnssConfiguration>> getExtensionGnssConfiguration() override;
+    Return<sp<V1_0::IGnssDebug>> getExtensionGnssDebug() override;
+    Return<sp<V1_0::IGnssBatching>> getExtensionGnssBatching() override;
+
+    // Methods from V1_1::IGnss follow.
+    Return<bool> setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) override;
+    Return<bool> setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode,
+                                     V1_0::IGnss::GnssPositionRecurrence recurrence,
+                                     uint32_t minIntervalMs, uint32_t preferredAccuracyMeters,
+                                     uint32_t preferredTimeMs, bool lowPowerMode) override;
+    Return<sp<V1_1::IGnssConfiguration>> getExtensionGnssConfiguration_1_1() override;
+    Return<sp<V1_1::IGnssMeasurement>> getExtensionGnssMeasurement_1_1() override;
+    Return<bool> injectBestLocation(const V1_0::GnssLocation& location) override;
+
+    // Methods from V2_0::IGnss follow.
+    Return<sp<V2_0::IGnssMeasurement>> getExtensionGnssMeasurement_2_0() override;
+    Return<bool> setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) override;
+    Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>>
+    getExtensionMeasurementCorrections() override;
+
+   private:
+    static sp<V2_0::IGnssCallback> sGnssCallback_2_0;
+    static sp<V1_1::IGnssCallback> sGnssCallback_1_1;
+};
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace gnss
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
\ No newline at end of file
diff --git a/gnss/2.0/default/GnssMeasurement.cpp b/gnss/2.0/default/GnssMeasurement.cpp
new file mode 100644
index 0000000..fbcdc12
--- /dev/null
+++ b/gnss/2.0/default/GnssMeasurement.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2018 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 "GnssMeasurement.h"
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V2_0 {
+namespace implementation {
+
+// Methods from V1_0::IGnssMeasurement follow.
+Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
+    const sp<V1_0::IGnssMeasurementCallback>&) {
+    // TODO implement
+    return V1_0::IGnssMeasurement::GnssMeasurementStatus{};
+}
+
+Return<void> GnssMeasurement::close() {
+    // TODO implement
+    return Void();
+}
+
+// Methods from V1_1::IGnssMeasurement follow.
+Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback_1_1(
+    const sp<V1_1::IGnssMeasurementCallback>&, bool) {
+    // TODO implement
+    return V1_0::IGnssMeasurement::GnssMeasurementStatus{};
+}
+
+// Methods from V2_0::IGnssMeasurement follow.
+Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback_2_0(
+    const sp<V2_0::IGnssMeasurementCallback>&, bool) {
+    // TODO implement
+    return V1_0::IGnssMeasurement::GnssMeasurementStatus{};
+}
+
+// Methods from ::android::hidl::base::V1_0::IBase follow.
+
+// IGnssMeasurement* HIDL_FETCH_IGnssMeasurement(const char* /* name */) {
+// return new GnssMeasurement();
+//}
+//
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace gnss
+}  // namespace hardware
+}  // namespace android
diff --git a/gnss/2.0/default/GnssMeasurement.h b/gnss/2.0/default/GnssMeasurement.h
new file mode 100644
index 0000000..8c621bb
--- /dev/null
+++ b/gnss/2.0/default/GnssMeasurement.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
+#define ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
+
+#include <android/hardware/gnss/2.0/IGnssMeasurement.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V2_0 {
+namespace implementation {
+
+using ::android::sp;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+
+struct GnssMeasurement : public IGnssMeasurement {
+    // Methods from V1_0::IGnssMeasurement follow.
+    Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> setCallback(
+        const sp<V1_0::IGnssMeasurementCallback>& callback) override;
+    Return<void> close() override;
+
+    // Methods from V1_1::IGnssMeasurement follow.
+    Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> setCallback_1_1(
+        const sp<V1_1::IGnssMeasurementCallback>& callback, bool enableFullTracking) override;
+
+    // Methods from V2_0::IGnssMeasurement follow.
+    Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> setCallback_2_0(
+        const sp<V2_0::IGnssMeasurementCallback>& callback, bool enableFullTracking) override;
+};
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace gnss
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
diff --git a/gnss/2.0/default/OWNERS b/gnss/2.0/default/OWNERS
new file mode 100644
index 0000000..8da956c
--- /dev/null
+++ b/gnss/2.0/default/OWNERS
@@ -0,0 +1,5 @@
+wyattriley@google.com
+gomo@google.com
+smalkos@google.com
+yuhany@google.com
+aadmal@google.com
diff --git a/gnss/2.0/default/android.hardware.gnss@2.0-service.rc b/gnss/2.0/default/android.hardware.gnss@2.0-service.rc
new file mode 100644
index 0000000..a27240d
--- /dev/null
+++ b/gnss/2.0/default/android.hardware.gnss@2.0-service.rc
@@ -0,0 +1,4 @@
+service vendor.gnss-2-0 /vendor/bin/hw/android.hardware.gnss@2.0-service
+    class hal
+    user system
+    group system
diff --git a/gnss/2.0/default/service.cpp b/gnss/2.0/default/service.cpp
new file mode 100644
index 0000000..301d181
--- /dev/null
+++ b/gnss/2.0/default/service.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "android.hardware.gnss@2.0-service"
+
+#include <hidl/HidlSupport.h>
+#include <hidl/HidlTransportSupport.h>
+#include "Gnss.h"
+
+using ::android::OK;
+using ::android::sp;
+using ::android::hardware::configureRpcThreadpool;
+using ::android::hardware::joinRpcThreadpool;
+using ::android::hardware::gnss::V2_0::IGnss;
+using ::android::hardware::gnss::V2_0::implementation::Gnss;
+
+int main(int /* argc */, char* /* argv */ []) {
+    sp<IGnss> gnss = new Gnss();
+    configureRpcThreadpool(1, true /* will join */);
+    if (gnss->registerAsService() != OK) {
+        ALOGE("Could not register gnss 2.0 service.");
+        return 1;
+    }
+    joinRpcThreadpool();
+
+    ALOGE("Service exited!");
+    return 1;
+}
diff --git a/gnss/2.0/vts/OWNERS b/gnss/2.0/vts/OWNERS
new file mode 100644
index 0000000..0a7ce6c
--- /dev/null
+++ b/gnss/2.0/vts/OWNERS
@@ -0,0 +1,8 @@
+wyattriley@google.com
+gomo@google.com
+smalkos@google.com
+yuhany@google.com
+aadmal@google.com
+
+# VTS team
+yim@google.com
diff --git a/audio/core/2.0/vts/functional/Android.bp b/gnss/2.0/vts/functional/Android.bp
similarity index 63%
rename from audio/core/2.0/vts/functional/Android.bp
rename to gnss/2.0/vts/functional/Android.bp
index d1ddaff..894716d 100644
--- a/audio/core/2.0/vts/functional/Android.bp
+++ b/gnss/2.0/vts/functional/Android.bp
@@ -1,5 +1,5 @@
 //
-// Copyright (C) 2017 The Android Open Source Project
+// Copyright (C) 2018 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.
@@ -15,18 +15,17 @@
 //
 
 cc_test {
-    name: "VtsHalAudioV2_0TargetTest",
+    name: "VtsHalGnssV2_0TargetTest",
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: [
-        "AudioPrimaryHidlHalTest.cpp",
-        "ValidateAudioConfiguration.cpp"
+        "gnss_hal_test.cpp",
+        "gnss_hal_test_cases.cpp",
+        "VtsHalGnssV2_0TargetTest.cpp",
     ],
     static_libs: [
-        "android.hardware.audio.common.test.utility",
-        "android.hardware.audio@2.0",
-        "android.hardware.audio.common@2.0",
-        "libicuuc",
-        "libicuuc_stubdata",
-        "libxml2",
+        "android.hardware.gnss.measurement_corrections@1.0",
+        "android.hardware.gnss@1.0",
+        "android.hardware.gnss@1.1",
+        "android.hardware.gnss@2.0",
     ],
 }
diff --git a/gnss/2.0/vts/functional/VtsHalGnssV2_0TargetTest.cpp b/gnss/2.0/vts/functional/VtsHalGnssV2_0TargetTest.cpp
new file mode 100644
index 0000000..ae36c50
--- /dev/null
+++ b/gnss/2.0/vts/functional/VtsHalGnssV2_0TargetTest.cpp
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2018 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 "VtsHalGnssV2_0TargetTest"
+
+#include <VtsHalHidlTargetTestBase.h>
+
+#include "gnss_hal_test.h"
+
+int main(int argc, char** argv) {
+    ::testing::AddGlobalTestEnvironment(GnssHidlEnvironment::Instance());
+    ::testing::InitGoogleTest(&argc, argv);
+    GnssHidlEnvironment::Instance()->init(&argc, argv);
+    int status = RUN_ALL_TESTS();
+    ALOGI("Test result = %d", status);
+    return status;
+}
diff --git a/gnss/2.0/vts/functional/gnss_hal_test.cpp b/gnss/2.0/vts/functional/gnss_hal_test.cpp
new file mode 100644
index 0000000..d7101a0
--- /dev/null
+++ b/gnss/2.0/vts/functional/gnss_hal_test.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2018 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 "GnssHalTest"
+
+#include <gnss_hal_test.h>
+
+#include <chrono>
+
+// Implementations for the main test class for GNSS HAL
+GnssHalTest::GnssHalTest()
+    : info_called_count_(0),
+      capabilities_called_count_(0),
+      location_called_count_(0),
+      name_called_count_(0),
+      notify_count_(0) {}
+
+void GnssHalTest::SetUp() {
+    gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>(
+        GnssHidlEnvironment::Instance()->getServiceName<IGnss>());
+    list_gnss_sv_status_.clear();
+    ASSERT_NE(gnss_hal_, nullptr);
+
+    SetUpGnssCallback();
+}
+
+void GnssHalTest::TearDown() {
+    if (gnss_hal_ != nullptr) {
+        gnss_hal_->cleanup();
+    }
+    if (notify_count_ > 0) {
+        ALOGW("%d unprocessed callbacks discarded", notify_count_);
+    }
+}
+
+void GnssHalTest::SetUpGnssCallback() {
+    gnss_cb_ = new GnssCallback(*this);
+    ASSERT_NE(gnss_cb_, nullptr);
+
+    auto result = gnss_hal_->setCallback_1_1(gnss_cb_);
+    if (!result.isOk()) {
+        ALOGE("result of failed setCallback %s", result.description().c_str());
+    }
+
+    ASSERT_TRUE(result.isOk());
+    ASSERT_TRUE(result);
+
+    /*
+     * All capabilities, name and systemInfo callbacks should trigger
+     */
+    EXPECT_EQ(std::cv_status::no_timeout, wait(TIMEOUT_SEC));
+    EXPECT_EQ(std::cv_status::no_timeout, wait(TIMEOUT_SEC));
+    EXPECT_EQ(std::cv_status::no_timeout, wait(TIMEOUT_SEC));
+
+    EXPECT_EQ(capabilities_called_count_, 1);
+    EXPECT_EQ(info_called_count_, 1);
+    EXPECT_EQ(name_called_count_, 1);
+}
+
+void GnssHalTest::notify() {
+    std::unique_lock<std::mutex> lock(mtx_);
+    notify_count_++;
+    cv_.notify_one();
+}
+
+std::cv_status GnssHalTest::wait(int timeout_seconds) {
+    std::unique_lock<std::mutex> lock(mtx_);
+
+    auto status = std::cv_status::no_timeout;
+    while (notify_count_ == 0) {
+        status = cv_.wait_for(lock, std::chrono::seconds(timeout_seconds));
+        if (status == std::cv_status::timeout) return status;
+    }
+    notify_count_--;
+    return status;
+}
+
+Return<void> GnssHalTest::GnssCallback::gnssSetSystemInfoCb(
+    const IGnssCallback::GnssSystemInfo& info) {
+    ALOGI("Info received, year %d", info.yearOfHw);
+    parent_.info_called_count_++;
+    parent_.last_info_ = info;
+    parent_.notify();
+    return Void();
+}
+
+Return<void> GnssHalTest::GnssCallback::gnssSetCapabilitesCb(uint32_t capabilities) {
+    ALOGI("Capabilities received %d", capabilities);
+    parent_.capabilities_called_count_++;
+    parent_.last_capabilities_ = capabilities;
+    parent_.notify();
+    return Void();
+}
+
+Return<void> GnssHalTest::GnssCallback::gnssNameCb(const android::hardware::hidl_string& name) {
+    ALOGI("Name received: %s", name.c_str());
+    parent_.name_called_count_++;
+    parent_.last_name_ = name;
+    parent_.notify();
+    return Void();
+}
+
+Return<void> GnssHalTest::GnssCallback::gnssLocationCb(const GnssLocation& location) {
+    ALOGI("Location received");
+    parent_.location_called_count_++;
+    parent_.last_location_ = location;
+    parent_.notify();
+    return Void();
+}
+
+Return<void> GnssHalTest::GnssCallback::gnssSvStatusCb(
+    const IGnssCallback::GnssSvStatus& svStatus) {
+    ALOGI("GnssSvStatus received");
+    parent_.list_gnss_sv_status_.emplace_back(svStatus);
+    return Void();
+}
diff --git a/gnss/2.0/vts/functional/gnss_hal_test.h b/gnss/2.0/vts/functional/gnss_hal_test.h
new file mode 100644
index 0000000..64f3575
--- /dev/null
+++ b/gnss/2.0/vts/functional/gnss_hal_test.h
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2018 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 GNSS_HAL_TEST_H_
+#define GNSS_HAL_TEST_H_
+
+#include <android/hardware/gnss/2.0/IGnss.h>
+
+#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
+
+#include <condition_variable>
+#include <list>
+#include <mutex>
+
+using android::hardware::Return;
+using android::hardware::Void;
+
+using android::hardware::gnss::V1_0::GnssLocation;
+
+using android::hardware::gnss::V1_0::GnssLocationFlags;
+using android::hardware::gnss::V1_1::IGnssCallback;
+using android::hardware::gnss::V2_0::IGnss;
+
+using android::sp;
+
+#define TIMEOUT_SEC 2  // for basic commands/responses
+
+// Test environment for GNSS HIDL HAL.
+class GnssHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+   public:
+    // get the test environment singleton
+    static GnssHidlEnvironment* Instance() {
+        static GnssHidlEnvironment* instance = new GnssHidlEnvironment;
+        return instance;
+    }
+
+    virtual void registerTestServices() override { registerTestService<IGnss>(); }
+
+   private:
+    GnssHidlEnvironment() {}
+};
+
+// The main test class for GNSS HAL.
+class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
+   public:
+    GnssHalTest();
+
+    virtual void SetUp() override;
+
+    virtual void TearDown() override;
+
+    /* Used as a mechanism to inform the test that a callback has occurred */
+    void notify();
+
+    /* Test code calls this function to wait for a callback */
+    std::cv_status wait(int timeout_seconds);
+
+    /* Callback class for data & Event. */
+    class GnssCallback : public IGnssCallback {
+       public:
+        GnssHalTest& parent_;
+
+        GnssCallback(GnssHalTest& parent) : parent_(parent){};
+
+        virtual ~GnssCallback() = default;
+
+        // Dummy callback handlers
+        Return<void> gnssStatusCb(const IGnssCallback::GnssStatusValue /* status */) override {
+            return Void();
+        }
+        Return<void> gnssNmeaCb(int64_t /* timestamp */,
+                                const android::hardware::hidl_string& /* nmea */) override {
+            return Void();
+        }
+        Return<void> gnssAcquireWakelockCb() override { return Void(); }
+        Return<void> gnssReleaseWakelockCb() override { return Void(); }
+        Return<void> gnssRequestLocationCb(bool /* independentFromGnss */) override {
+            return Void();
+        }
+        Return<void> gnssRequestTimeCb() override { return Void(); }
+        // Actual (test) callback handlers
+        Return<void> gnssNameCb(const android::hardware::hidl_string& name) override;
+        Return<void> gnssLocationCb(const GnssLocation& location) override;
+        Return<void> gnssSetCapabilitesCb(uint32_t capabilities) override;
+        Return<void> gnssSetSystemInfoCb(const IGnssCallback::GnssSystemInfo& info) override;
+        Return<void> gnssSvStatusCb(const IGnssCallback::GnssSvStatus& svStatus) override;
+    };
+
+    /*
+     * SetUpGnssCallback:
+     *   Set GnssCallback and verify the result.
+     */
+    void SetUpGnssCallback();
+
+    sp<IGnss> gnss_hal_;         // GNSS HAL to call into
+    sp<IGnssCallback> gnss_cb_;  // Primary callback interface
+
+    /* Count of calls to set the following items, and the latest item (used by
+     * test.)
+     */
+    int info_called_count_;
+    IGnssCallback::GnssSystemInfo last_info_;
+    uint32_t last_capabilities_;
+    int capabilities_called_count_;
+    int location_called_count_;
+    GnssLocation last_location_;
+    list<IGnssCallback::GnssSvStatus> list_gnss_sv_status_;
+
+    int name_called_count_;
+    android::hardware::hidl_string last_name_;
+
+   private:
+    std::mutex mtx_;
+    std::condition_variable cv_;
+    int notify_count_;
+};
+
+#endif  // GNSS_HAL_TEST_H_
diff --git a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
new file mode 100644
index 0000000..12a15e8
--- /dev/null
+++ b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2018 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 "GnssHalTestCases"
+
+#include <VtsHalHidlTargetTestBase.h>
+#include <gnss_hal_test.h>
+
+using android::hardware::hidl_vec;
+
+using IGnssMeasurement_2_0 = android::hardware::gnss::V2_0::IGnssMeasurement;
+using IGnssMeasurement_1_1 = android::hardware::gnss::V1_1::IGnssMeasurement;
+
+/*
+ * SetupTeardownCreateCleanup:
+ * Requests the gnss HAL then calls cleanup
+ *
+ * Empty test fixture to verify basic Setup & Teardown
+ */
+TEST_F(GnssHalTest, SetupTeardownCreateCleanup) {}
+
+/*
+ * TestGnssMeasurementCallback:
+ * Gets the GnssMeasurementExtension and verify that it returns an actual extension.
+ */
+TEST_F(GnssHalTest, TestGnssMeasurementCallback) {
+    auto gnssMeasurement_2_0 = gnss_hal_->getExtensionGnssMeasurement_2_0();
+    auto gnssMeasurement_1_1 = gnss_hal_->getExtensionGnssMeasurement_1_1();
+    ASSERT_TRUE(gnssMeasurement_2_0.isOk() || gnssMeasurement_1_1.isOk());
+    if (last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENTS) {
+        sp<IGnssMeasurement_2_0> iGnssMeas_2_0 = gnssMeasurement_2_0;
+        sp<IGnssMeasurement_1_1> iGnssMeas_1_1 = gnssMeasurement_1_1;
+        // Exactly one interface is non-null.
+        ASSERT_TRUE((iGnssMeas_1_1 != nullptr) != (iGnssMeas_2_0 != nullptr));
+    }
+}
diff --git a/gnss/measurement_corrections/1.0/Android.bp b/gnss/measurement_corrections/1.0/Android.bp
new file mode 100644
index 0000000..237b008
--- /dev/null
+++ b/gnss/measurement_corrections/1.0/Android.bp
@@ -0,0 +1,25 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.gnss.measurement_corrections@1.0",
+    root: "android.hardware",
+    vndk: {
+        enabled: true,
+    },
+    srcs: [
+        "types.hal",
+        "IMeasurementCorrections.hal",
+    ],
+    interfaces: [
+        "android.hardware.gnss@1.0",
+        "android.hidl.base@1.0",
+    ],
+    types: [
+        "GnssSingleSatCorrectionFlags",
+        "MeasurementCorrections",
+        "ReflectingPlane",
+        "SingleSatCorrection",
+    ],
+    gen_java: true,
+}
+
diff --git a/gnss/measurement_corrections/1.0/IMeasurementCorrections.hal b/gnss/measurement_corrections/1.0/IMeasurementCorrections.hal
new file mode 100644
index 0000000..934d10f
--- /dev/null
+++ b/gnss/measurement_corrections/1.0/IMeasurementCorrections.hal
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.gnss.measurement_corrections@1.0;
+
+/**
+ * Interface for measurement corrections support.
+ */
+interface IMeasurementCorrections {
+
+    /**
+     * Injects measurement corrections to be used by the HAL to improve the GNSS location output.
+     *
+     * These are NOT to be used to adjust the IGnssMeasurementCallback output values -
+     * those remain raw, uncorrected measurements.
+     *
+     * In general, these are injected when conditions defined by the platform are met, such as when
+     * GNSS Location is being requested at a sufficiently high accuracy, based on the capabilities
+     * of the GNSS chipset as reported in the IGnssCallback.
+     *
+     * @param corrections The computed corrections to be used by the HAL.
+     *
+     * @return success Whether the HAL can accept & use these corrections.
+     */
+     setCorrections(MeasurementCorrections corrections) generates (bool success);
+};
diff --git a/gnss/measurement_corrections/1.0/types.hal b/gnss/measurement_corrections/1.0/types.hal
new file mode 100644
index 0000000..192bec9
--- /dev/null
+++ b/gnss/measurement_corrections/1.0/types.hal
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.gnss.measurement_corrections@1.0;
+
+import android.hardware.gnss@1.0::GnssConstellationType;
+
+/**
+ * A struct with measurement corrections for a single visible satellites
+ *
+ * The bit mask singleSatCorrectionFlags indicates which correction values are valid in the struct
+ */
+struct SingleSatCorrection {
+
+    /** Contains GnssSingleSatCorrectionFlags bits. */
+    bitfield<GnssSingleSatCorrectionFlags> singleSatCorrectionFlags;
+
+    /**
+     * Defines the constellation of the given satellite.
+     */
+    GnssConstellationType constellation;
+
+    /**
+     * Satellite vehicle ID number, as defined in GnssSvInfo::svid
+     */
+    uint16_t svid;
+
+    /**
+     * Carrier frequency of the signal to be corrected, for example it can be the
+     * GPS center frequency for L1 = 1,575,420,000 Hz, varying GLO channels, etc.
+     *
+     * For a receiver with capabilities to track multiple frequencies for the same satellite,
+     * multiple corrections for the same satellite may be provided.
+     */
+    float carrierFrequencyHz;
+
+    /** True if the satellite is in Line-of-Sight condition */
+    bool satIsLos;
+
+    /**
+     * Excess path length to be subtracted from pseudorange before using it in calculating location.
+     *
+     * Note this value is NOT to be used to adjust the GnssMeasurementCallback outputs.
+     */
+    float excessPathLengthMeters;
+
+    /** Error estimate (1-sigma) for the Excess path length estimate */
+    float excessPathLengthUncertaintyMeters;
+
+    /** Defines the reflecting plane location and azimuth information */
+    ReflectingPlane reflectingPlance;
+};
+
+/**
+ * A struct containing a set of measurement corrections for all used GNSS satellites at the location
+ * specified by latitudeDegrees, longitudeDegrees, altitudeMeters and at the time of week specified
+ * toaGpsNanosecondsOfWeek
+ */
+struct MeasurementCorrections {
+    /** Represents latitude in degrees. */
+    double latitudeDegrees;
+
+    /** Represents longitude in degrees. */
+    double longitudeDegrees;
+
+    /**
+     * Represents altitude in meters above the WGS 84 reference ellipsoid.
+     */
+    double altitudeMeters;
+
+    /** Time Of Applicability, GPS time of week */
+    uint64_t toaGpsNanosecondsOfWeek;
+
+    /**
+     * A set of SingleSatCorrection each containing measurement corrections for a satellite in view
+     */
+    vec<SingleSatCorrection> satCorrections;
+};
+
+/**
+ * A struct containing the location and azimuth of the reflecting plane that the satellite signal
+ * has bounced from.
+ *
+ * This field is set only if the signal has bounced only once.
+ */
+struct ReflectingPlane {
+    /** Represents latitude of the reflecting plane in degrees. */
+    double latitudeDegrees;
+
+    /** Represents longitude of the reflecting plane in degrees. */
+    double longitudeDegrees;
+
+    /**
+     * Represents altitude of the reflecting plane in meters above the WGS 84 reference ellipsoid.
+     */
+    double altitudeMeters;
+
+    /** Represents azimuth clockwise from north of the reflecting plane in degrees. */
+    double azimuthDegrees;
+};
+
+/** Bit mask to indicate which values are valid in a SingleSatCorrection object. */
+enum GnssSingleSatCorrectionFlags : uint16_t {
+    /** GnssSingleSatCorrectionFlags has valid satellite-is-line-of-sight field. */
+    HAS_SAT_IS_LOS                           = 0x0001,
+    /** GnssSingleSatCorrectionFlags has valid Excess Path Length field. */
+    HAS_EXCESS_PATH_LENGTH                   = 0x0002,
+    /** GnssSingleSatCorrectionFlags has valid Excess Path Length Uncertainty field. */
+    HAS_EXCESS_PATH_LENGTH_UNC               = 0x0004,
+    /** GnssSingleSatCorrectionFlags has valid Reflecting Plane field. */
+    HAS_REFLECTING_PLANE                     = 0x0008
+};
\ No newline at end of file
diff --git a/graphics/composer/2.1/vts/functional/Android.bp b/graphics/composer/2.1/vts/functional/Android.bp
index 8e346df..c98cc0d 100644
--- a/graphics/composer/2.1/vts/functional/Android.bp
+++ b/graphics/composer/2.1/vts/functional/Android.bp
@@ -34,4 +34,5 @@
     header_libs: [
         "android.hardware.graphics.composer@2.1-command-buffer",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
index 0a3e88b..4018aea 100644
--- a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
+++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
@@ -577,14 +577,6 @@
     }
 
     modes.clear();
-
-    modes.push_back(IComposerClient::PowerMode::ON);
-    modes.push_back(IComposerClient::PowerMode::ON);
-    for (auto mode : modes) {
-        ASSERT_NO_FATAL_FAILURE(mComposerClient->setPowerMode(mPrimaryDisplay, mode));
-    }
-
-    modes.clear();
     if (mComposerClient->getDozeSupport(mPrimaryDisplay)) {
         modes.push_back(IComposerClient::PowerMode::DOZE);
         modes.push_back(IComposerClient::PowerMode::DOZE);
@@ -602,6 +594,14 @@
             ASSERT_NO_FATAL_FAILURE(mComposerClient->setPowerMode(mPrimaryDisplay, mode));
         }
     }
+
+    modes.clear();
+
+    modes.push_back(IComposerClient::PowerMode::ON);
+    modes.push_back(IComposerClient::PowerMode::ON);
+    for (auto mode : modes) {
+        ASSERT_NO_FATAL_FAILURE(mComposerClient->setPowerMode(mPrimaryDisplay, mode));
+    }
 }
 
 /**
diff --git a/graphics/composer/2.2/utils/hal/include/composer-hal/2.2/ComposerClient.h b/graphics/composer/2.2/utils/hal/include/composer-hal/2.2/ComposerClient.h
index a6871fb..c760d0a 100644
--- a/graphics/composer/2.2/utils/hal/include/composer-hal/2.2/ComposerClient.h
+++ b/graphics/composer/2.2/utils/hal/include/composer-hal/2.2/ComposerClient.h
@@ -132,24 +132,13 @@
 
     Return<void> getRenderIntents(Display display, ColorMode mode,
                                   IComposerClient::getRenderIntents_cb hidl_cb) override {
-#ifdef USES_DISPLAY_RENDER_INTENTS
         std::vector<RenderIntent> intents;
         Error err = mHal->getRenderIntents(display, mode, &intents);
         hidl_cb(err, intents);
-#else
-        (void)display;
-        (void)mode;
-        hidl_cb(Error::NONE, hidl_vec<RenderIntent>({RenderIntent::COLORIMETRIC}));
-#endif
         return Void();
     }
 
     Return<Error> setColorMode_2_2(Display display, ColorMode mode, RenderIntent intent) override {
-#ifndef USES_DISPLAY_RENDER_INTENTS
-        if (intent != RenderIntent::COLORIMETRIC) {
-            return Error::BAD_PARAMETER;
-        }
-#endif
         return mHal->setColorMode_2_2(display, mode, intent);
     }
 
diff --git a/graphics/composer/2.2/vts/functional/Android.bp b/graphics/composer/2.2/vts/functional/Android.bp
index acc9245..b62f302 100644
--- a/graphics/composer/2.2/vts/functional/Android.bp
+++ b/graphics/composer/2.2/vts/functional/Android.bp
@@ -44,4 +44,5 @@
         "android.hardware.graphics.composer@2.1-command-buffer",
         "android.hardware.graphics.composer@2.2-command-buffer",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/graphics/composer/2.3/IComposerClient.hal b/graphics/composer/2.3/IComposerClient.hal
index 7856658..e5ee3c5 100644
--- a/graphics/composer/2.3/IComposerClient.hal
+++ b/graphics/composer/2.3/IComposerClient.hal
@@ -27,6 +27,42 @@
 
 interface IComposerClient extends @2.2::IComposerClient {
 
+    // TODO: Move this enum to LLNDK after we decide where to put graphic types.
+    /**
+     * Required capabilities which are supported by the display. The
+     * particular set of supported capabilities for a given display may be
+     * retrieved using getDisplayCapabilities.
+     */
+    enum DisplayCapability : uint32_t {
+        INVALID = 0,
+
+        /**
+         * Indicates that the display must apply a color transform even when
+         * either the client or the device has chosen that all layers should
+         * be composed by the client. This prevents the client from applying
+         * the color transform during its composition step.
+         * If getDisplayCapabilities is supported, the global capability
+         * SKIP_CLIENT_COLOR_TRANSFORM is ignored.
+         * If getDisplayCapabilities is not supported, and the global capability
+         * SKIP_CLIENT_COLOR_TRANSFORM is returned by getCapabilities,
+         * then all displays must be treated as having
+         * SKIP_CLIENT_COLOR_TRANSFORM.
+         */
+        SKIP_CLIENT_COLOR_TRANSFORM = 1,
+
+        /**
+         * Indicates that the display supports PowerMode::DOZE and
+         * PowerMode::DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit
+         * over DOZE (see the definition of PowerMode for more information),
+         * but if both DOZE and DOZE_SUSPEND are no different from
+         * PowerMode::ON, the device must not claim support.
+         * Must be returned by getDisplayCapabilities when getDozeSupport
+         * indicates the display supports PowerMode::DOZE and
+         * PowerMode::DOZE_SUSPEND.
+         */
+        DOZE = 2,
+    };
+
     enum Command : @2.2::IComposerClient.Command {
         /**
          * SET_LAYER_COLOR_TRANSFORM has this pseudo prototype
@@ -350,4 +386,17 @@
      */
     setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent)
           generates (Error error);
+
+    /**
+     * Provides a list of supported capabilities (as described in the
+     * definition of DisplayCapability above). This list must not change after
+     * initialization.
+     *
+     * @return error is NONE upon success. Otherwise,
+     *     BAD_DISPLAY when an invalid display handle was passed in.
+     * @return capabilities is a list of supported capabilities.
+     */
+    getDisplayCapabilities(Display display)
+              generates (Error error,
+                         vec<DisplayCapability> capabilities);
 };
diff --git a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h
index be0ef4c..69872d2 100644
--- a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h
+++ b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h
@@ -73,6 +73,14 @@
         return err;
     }
 
+    Return<void> getDisplayCapabilities(
+        Display display, IComposerClient::getDisplayCapabilities_cb hidl_cb) override {
+        hidl_vec<IComposerClient::DisplayCapability> capabilities;
+        Error error = mHal->getDisplayCapabilities(display, &capabilities);
+        hidl_cb(error, capabilities);
+        return Void();
+    }
+
     static std::unique_ptr<ComposerClientImpl> create(Hal* hal) {
         auto client = std::make_unique<ComposerClientImpl>(hal);
         return client->init() ? std::move(client) : nullptr;
diff --git a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h
index 8ca5d75..c7de848 100644
--- a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h
+++ b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h
@@ -84,6 +84,8 @@
                                             hidl_vec<uint64_t>& sampleComponent1,
                                             hidl_vec<uint64_t>& sampleComponent2,
                                             hidl_vec<uint64_t>& sampleComponent3) = 0;
+    virtual Error getDisplayCapabilities(
+        Display display, hidl_vec<IComposerClient::DisplayCapability>* outCapabilities) = 0;
 };
 
 }  // namespace hal
diff --git a/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h b/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h
index 8d444c8..f7ce7e8 100644
--- a/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h
+++ b/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h
@@ -163,6 +163,29 @@
         return static_cast<Error>(errorRaw);
     }
 
+    Error getDisplayCapabilities(
+        Display display, hidl_vec<IComposerClient::DisplayCapability>* outCapabilities) override {
+        if (!mDispatch.getDisplayCapabilities) {
+            return Error::UNSUPPORTED;
+        }
+
+        uint32_t count = 0;
+        int32_t error = mDispatch.getDisplayCapabilities(mDevice, display, &count, nullptr);
+        if (error != HWC2_ERROR_NONE) {
+            return static_cast<Error>(error);
+        }
+        outCapabilities->resize(count);
+        error = mDispatch.getDisplayCapabilities(
+            mDevice, display, &count,
+            reinterpret_cast<std::underlying_type<IComposerClient::DisplayCapability>::type*>(
+                outCapabilities->data()));
+        if (error != HWC2_ERROR_NONE) {
+            *outCapabilities = hidl_vec<IComposerClient::DisplayCapability>();
+            return static_cast<Error>(error);
+        }
+        return Error::NONE;
+    }
+
    protected:
     bool initDispatch() override {
         if (!BaseType2_2::initDispatch()) {
@@ -179,6 +202,8 @@
                                    &mDispatch.setDisplayedContentSamplingEnabled);
         this->initOptionalDispatch(HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE,
                                    &mDispatch.getDisplayedContentSample);
+        this->initOptionalDispatch(HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES,
+                                   &mDispatch.getDisplayCapabilities);
         return true;
     }
 
@@ -189,6 +214,7 @@
         HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES getDisplayedContentSamplingAttributes;
         HWC2_PFN_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED setDisplayedContentSamplingEnabled;
         HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLE getDisplayedContentSample;
+        HWC2_PFN_GET_DISPLAY_CAPABILITIES getDisplayCapabilities;
     } mDispatch = {};
 
     using BaseType2_2 = V2_2::passthrough::detail::HwcHalImpl<Hal>;
diff --git a/graphics/composer/2.3/utils/vts/ComposerVts.cpp b/graphics/composer/2.3/utils/vts/ComposerVts.cpp
index 9304992..c631c50 100644
--- a/graphics/composer/2.3/utils/vts/ComposerVts.cpp
+++ b/graphics/composer/2.3/utils/vts/ComposerVts.cpp
@@ -150,6 +150,15 @@
     return error;
 }
 
+std::vector<IComposerClient::DisplayCapability> ComposerClient::getDisplayCapabilities(
+    Display display) {
+    std::vector<IComposerClient::DisplayCapability> capabilities;
+    mClient->getDisplayCapabilities(
+        display, [&](const auto&, const auto& tmpCapabilities) { capabilities = tmpCapabilities; });
+
+    return capabilities;
+}
+
 }  // namespace vts
 }  // namespace V2_3
 }  // namespace composer
diff --git a/graphics/composer/2.3/utils/vts/include/composer-vts/2.3/ComposerVts.h b/graphics/composer/2.3/utils/vts/include/composer-vts/2.3/ComposerVts.h
index 4b9c955..d3aa779 100644
--- a/graphics/composer/2.3/utils/vts/include/composer-vts/2.3/ComposerVts.h
+++ b/graphics/composer/2.3/utils/vts/include/composer-vts/2.3/ComposerVts.h
@@ -91,6 +91,7 @@
 
     bool getClientTargetSupport_2_3(Display display, uint32_t width, uint32_t height,
                                     PixelFormat format, Dataspace dataspace);
+    std::vector<IComposerClient::DisplayCapability> getDisplayCapabilities(Display display);
 
    private:
     const sp<IComposerClient> mClient;
diff --git a/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp b/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp
index a294825..6c5cb5d 100644
--- a/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp
+++ b/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp
@@ -427,6 +427,23 @@
     }
 }
 
+/*
+ * getDisplayCapabilities is required in composer 2.3
+ * Test some constraints.
+ */
+TEST_F(GraphicsComposerHidlTest, getDisplayCapabilitiesBasic) {
+    auto capabilities = mComposerClient->getDisplayCapabilities(mPrimaryDisplay);
+    bool hasDozeSupport = std::find(capabilities.begin(), capabilities.end(),
+                                    IComposerClient::DisplayCapability::DOZE) != capabilities.end();
+    EXPECT_EQ(mComposerClient->getDozeSupport(mPrimaryDisplay), hasDozeSupport);
+}
+
+TEST_F(GraphicsComposerHidlTest, getDisplayCapabilitiesBadDisplay) {
+    mComposerClient->getRaw()->getDisplayCapabilities(
+        mInvalidDisplayId,
+        [&](const auto& tmpError, const auto&) { EXPECT_EQ(Error::BAD_DISPLAY, tmpError); });
+}
+
 }  // namespace
 }  // namespace vts
 }  // namespace V2_3
diff --git a/graphics/mapper/2.0/vts/functional/Android.bp b/graphics/mapper/2.0/vts/functional/Android.bp
index 969317a..853c2a3 100644
--- a/graphics/mapper/2.0/vts/functional/Android.bp
+++ b/graphics/mapper/2.0/vts/functional/Android.bp
@@ -24,4 +24,5 @@
         "android.hardware.graphics.mapper@2.0",
         "android.hardware.graphics.mapper@2.0-vts",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/graphics/mapper/2.1/vts/functional/Android.bp b/graphics/mapper/2.1/vts/functional/Android.bp
index ac67af8..afd8e7f 100644
--- a/graphics/mapper/2.1/vts/functional/Android.bp
+++ b/graphics/mapper/2.1/vts/functional/Android.bp
@@ -26,4 +26,5 @@
         "android.hardware.graphics.mapper@2.0-vts",
         "android.hardware.graphics.mapper@2.1-vts",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/health/1.0/vts/functional/Android.bp b/health/1.0/vts/functional/Android.bp
index 8742651..c14dcee 100644
--- a/health/1.0/vts/functional/Android.bp
+++ b/health/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalHealthV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.health@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/health/2.0/vts/functional/Android.bp b/health/2.0/vts/functional/Android.bp
index 4ad01b9..3544e5f 100644
--- a/health/2.0/vts/functional/Android.bp
+++ b/health/2.0/vts/functional/Android.bp
@@ -22,4 +22,5 @@
         "android.hardware.health@1.0",
         "android.hardware.health@2.0",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/health/storage/1.0/vts/functional/Android.bp b/health/storage/1.0/vts/functional/Android.bp
index 63591cf..250a7dc 100644
--- a/health/storage/1.0/vts/functional/Android.bp
+++ b/health/storage/1.0/vts/functional/Android.bp
@@ -22,5 +22,6 @@
     shared_libs: [
         "libhidltransport"
     ],
+    test_suites: ["general-tests"],
 }
 
diff --git a/ir/1.0/vts/functional/Android.bp b/ir/1.0/vts/functional/Android.bp
index 2a86f8e..f5c9d61 100644
--- a/ir/1.0/vts/functional/Android.bp
+++ b/ir/1.0/vts/functional/Android.bp
@@ -21,4 +21,5 @@
     static_libs: [
         "android.hardware.ir@1.0",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/keymaster/3.0/vts/functional/Android.bp b/keymaster/3.0/vts/functional/Android.bp
index 7d96704..b0371c7 100644
--- a/keymaster/3.0/vts/functional/Android.bp
+++ b/keymaster/3.0/vts/functional/Android.bp
@@ -29,4 +29,5 @@
         "libcrypto",
         "libsoftkeymasterdevice",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/keymaster/3.0/vts/functional/authorization_set.h b/keymaster/3.0/vts/functional/authorization_set.h
index 5f92d81..0c15e68 100644
--- a/keymaster/3.0/vts/functional/authorization_set.h
+++ b/keymaster/3.0/vts/functional/authorization_set.h
@@ -201,7 +201,7 @@
     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));
+        push_back(ttag, new_blob);
     }
 
     /**
@@ -225,8 +225,7 @@
     }
 
     hidl_vec<KeyParameter> hidl_data() const {
-        hidl_vec<KeyParameter> result;
-        result.setToExternal(const_cast<KeyParameter*>(data()), size());
+        hidl_vec<KeyParameter> result(begin(), end());
         return result;
     }
 
@@ -252,7 +251,7 @@
                                            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));
+        push_back(ttag, new_blob);
         return *this;
     }
 
@@ -262,6 +261,12 @@
         return Authorization(ttag, reinterpret_cast<const uint8_t*>(data), data_length);
     }
 
+    template <Tag tag>
+    AuthorizationSetBuilder& Authorization(TypedTag<TagType::BYTES, tag> ttag, 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);
 
diff --git a/keymaster/4.0/support/authorization_set.cpp b/keymaster/4.0/support/authorization_set.cpp
index afbcdac..d6b50f5 100644
--- a/keymaster/4.0/support/authorization_set.cpp
+++ b/keymaster/4.0/support/authorization_set.cpp
@@ -18,6 +18,8 @@
 
 #include <assert.h>
 
+#include <android-base/logging.h>
+
 namespace android {
 namespace hardware {
 namespace keymaster {
@@ -97,10 +99,10 @@
         if (prev->tag == Tag::INVALID) continue;
 
         if (!keyParamEqual(*prev, *curr)) {
-            result.emplace_back(std::move(*prev));
+            result.push_back(std::move(*prev));
         }
     }
-    result.emplace_back(std::move(*prev));
+    result.push_back(std::move(*prev));
 
     std::swap(data_, result);
 }
@@ -127,6 +129,16 @@
     }
 }
 
+void AuthorizationSet::Filter(std::function<bool(const KeyParameter&)> doKeep) {
+    std::vector<KeyParameter> result;
+    for (auto& param : data_) {
+        if (doKeep(param)) {
+            result.push_back(std::move(param));
+        }
+    }
+    std::swap(data_, result);
+}
+
 KeyParameter& AuthorizationSet::operator[](int at) {
     return data_[at];
 }
@@ -191,6 +203,7 @@
 struct OutStreams {
     std::ostream& indirect;
     std::ostream& elements;
+    size_t skipped;
 };
 
 OutStreams& serializeParamValue(OutStreams& out, const hidl_vec<uint8_t>& blob) {
@@ -229,6 +242,7 @@
 
 OutStreams& serialize(TAG_INVALID_t&&, OutStreams& out, const KeyParameter&) {
     // skip invalid entries.
+    ++out.skipped;
     return out;
 }
 template <typename T>
@@ -248,7 +262,12 @@
 
 template <>
 struct choose_serializer<> {
-    static OutStreams& serialize(OutStreams& out, const KeyParameter&) { return out; }
+    static OutStreams& serialize(OutStreams& out, const KeyParameter& param) {
+        LOG(WARNING) << "Trying to serialize unknown tag " << unsigned(param.tag)
+                     << ". Did you forget to add it to all_tags_t?";
+        ++out.skipped;
+        return out;
+    }
 };
 
 template <TagType tag_type, Tag tag, typename... Tail>
@@ -269,7 +288,7 @@
 std::ostream& serialize(std::ostream& out, const std::vector<KeyParameter>& params) {
     std::stringstream indirect;
     std::stringstream elements;
-    OutStreams streams = {indirect, elements};
+    OutStreams streams = {indirect, elements, 0};
     for (const auto& param : params) {
         serialize(streams, param);
     }
@@ -289,7 +308,7 @@
         return out;
     }
     uint32_t elements_size = pos;
-    uint32_t element_count = params.size();
+    uint32_t element_count = params.size() - streams.skipped;
 
     out.write(reinterpret_cast<const char*>(&indirect_size), sizeof(uint32_t));
 
@@ -310,6 +329,7 @@
 struct InStreams {
     std::istream& indirect;
     std::istream& elements;
+    size_t invalids;
 };
 
 InStreams& deserializeParamValue(InStreams& in, hidl_vec<uint8_t>* blob) {
@@ -331,6 +351,7 @@
 
 InStreams& deserialize(TAG_INVALID_t&&, InStreams& in, KeyParameter*) {
     // there should be no invalid KeyParamaters but if handle them as zero sized.
+    ++in.invalids;
     return in;
 }
 
@@ -398,13 +419,28 @@
     // TODO write one-shot stream buffer to avoid copying here
     std::stringstream indirect(indirect_buffer);
     std::stringstream elements(elements_buffer);
-    InStreams streams = {indirect, elements};
+    InStreams streams = {indirect, elements, 0};
 
     params->resize(element_count);
 
     for (uint32_t i = 0; i < element_count; ++i) {
         deserialize(streams, &(*params)[i]);
     }
+
+    /*
+     * There are legacy blobs which have invalid tags in them due to a bug during serialization.
+     * This makes sure that invalid tags are filtered from the result before it is returned.
+     */
+    if (streams.invalids > 0) {
+        std::vector<KeyParameter> filtered(element_count - streams.invalids);
+        auto ifiltered = filtered.begin();
+        for (auto& p : *params) {
+            if (p.tag != Tag::INVALID) {
+                *ifiltered++ = std::move(p);
+            }
+        }
+        *params = std::move(filtered);
+    }
     return in;
 }
 
diff --git a/keymaster/4.0/support/include/keymasterV4_0/Keymaster.h b/keymaster/4.0/support/include/keymasterV4_0/Keymaster.h
index 83b1d69..458053a 100644
--- a/keymaster/4.0/support/include/keymasterV4_0/Keymaster.h
+++ b/keymaster/4.0/support/include/keymasterV4_0/Keymaster.h
@@ -20,6 +20,9 @@
 
 #include <android/hardware/keymaster/4.0/IKeymasterDevice.h>
 
+#include <memory>
+#include <vector>
+
 namespace android {
 namespace hardware {
 namespace keymaster {
diff --git a/keymaster/4.0/support/include/keymasterV4_0/authorization_set.h b/keymaster/4.0/support/include/keymasterV4_0/authorization_set.h
index 193e4ea..ff08066 100644
--- a/keymaster/4.0/support/include/keymasterV4_0/authorization_set.h
+++ b/keymaster/4.0/support/include/keymasterV4_0/authorization_set.h
@@ -142,6 +142,11 @@
     std::vector<KeyParameter>::const_iterator end() const { return data_.end(); }
 
     /**
+     * Modifies this Authorization set such that it only keeps the entries for which doKeep
+     * returns true.
+     */
+    void Filter(std::function<bool(const KeyParameter&)> doKeep);
+    /**
      * 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.
@@ -210,8 +215,7 @@
     }
 
     hidl_vec<KeyParameter> hidl_data() const {
-        hidl_vec<KeyParameter> result;
-        result.setToExternal(const_cast<KeyParameter*>(data()), size());
+        hidl_vec<KeyParameter> result(begin(), end());
         return result;
     }
 
@@ -237,7 +241,7 @@
                                            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));
+        push_back(ttag, new_blob);
         return *this;
     }
 
@@ -247,6 +251,12 @@
         return Authorization(ttag, reinterpret_cast<const uint8_t*>(data), data_length);
     }
 
+    template <Tag tag>
+    AuthorizationSetBuilder& Authorization(TypedTag<TagType::BYTES, tag> ttag, char* data,
+                                           size_t data_length) {
+        return Authorization(ttag, reinterpret_cast<const uint8_t*>(data), data_length);
+    }
+
     AuthorizationSetBuilder& Authorizations(const AuthorizationSet& set) {
         for (const auto& entry : set) {
             push_back(entry);
diff --git a/keymaster/4.0/support/include/keymasterV4_0/keymaster_tags.h b/keymaster/4.0/support/include/keymasterV4_0/keymaster_tags.h
index 9e7d252..61c444c 100644
--- a/keymaster/4.0/support/include/keymasterV4_0/keymaster_tags.h
+++ b/keymaster/4.0/support/include/keymasterV4_0/keymaster_tags.h
@@ -122,6 +122,7 @@
 DECLARE_TYPED_TAG(CREATION_DATETIME);
 DECLARE_TYPED_TAG(DIGEST);
 DECLARE_TYPED_TAG(EC_CURVE);
+DECLARE_TYPED_TAG(HARDWARE_TYPE);
 DECLARE_TYPED_TAG(INCLUDE_UNIQUE_ID);
 DECLARE_TYPED_TAG(INVALID);
 DECLARE_TYPED_TAG(KEY_SIZE);
@@ -162,12 +163,13 @@
              TAG_USER_SECURE_ID_t, TAG_NO_AUTH_REQUIRED_t, TAG_AUTH_TIMEOUT_t,
              TAG_ALLOW_WHILE_ON_BODY_t, TAG_UNLOCKED_DEVICE_REQUIRED_t, TAG_APPLICATION_ID_t,
              TAG_APPLICATION_DATA_t, TAG_CREATION_DATETIME_t, TAG_ROLLBACK_RESISTANCE_t,
-             TAG_ROOT_OF_TRUST_t, TAG_ASSOCIATED_DATA_t, TAG_NONCE_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_EC_CURVE_t,
-             TAG_BOOT_PATCHLEVEL_t, TAG_VENDOR_PATCHLEVEL_t, TAG_TRUSTED_USER_PRESENCE_REQUIRED_t>;
+             TAG_HARDWARE_TYPE_t, TAG_ROOT_OF_TRUST_t, TAG_ASSOCIATED_DATA_t, TAG_NONCE_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_EC_CURVE_t, TAG_BOOT_PATCHLEVEL_t, TAG_VENDOR_PATCHLEVEL_t,
+             TAG_TRUSTED_CONFIRMATION_REQUIRED_t, TAG_TRUSTED_USER_PRESENCE_REQUIRED_t>;
 
 template <typename TypedTagType>
 struct TypedTag2ValueType;
@@ -220,6 +222,7 @@
 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)
+MAKE_TAG_ENUM_VALUE_ACCESSOR(TAG_HARDWARE_TYPE, f.hardwareType)
 
 template <TagType tag_type, Tag tag, typename ValueT>
 inline KeyParameter makeKeyParameter(TypedTag<tag_type, tag> ttag, ValueT&& value) {
diff --git a/keymaster/4.0/support/include/keymasterV4_0/keymaster_utils.h b/keymaster/4.0/support/include/keymasterV4_0/keymaster_utils.h
index 90a0f1b..5e5ae8d 100644
--- a/keymaster/4.0/support/include/keymasterV4_0/keymaster_utils.h
+++ b/keymaster/4.0/support/include/keymasterV4_0/keymaster_utils.h
@@ -33,25 +33,19 @@
 
 namespace support {
 
-inline static hidl_vec<uint8_t> blob2hidlVec(const uint8_t* data, const size_t length,
-                                             bool inPlace = true) {
-    hidl_vec<uint8_t> result;
-    result.setToExternal(const_cast<unsigned char*>(data), length, !inPlace);
+inline static hidl_vec<uint8_t> blob2hidlVec(const uint8_t* data, const size_t length) {
+    hidl_vec<uint8_t> result(data, data + length);
     return result;
 }
 
-inline static hidl_vec<uint8_t> blob2hidlVec(const std::string& value, bool inPlace = true) {
-    hidl_vec<uint8_t> result;
-    result.setToExternal(const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(value.data())),
-                         static_cast<size_t>(value.size()), !inPlace);
+inline static hidl_vec<uint8_t> blob2hidlVec(const std::string& value) {
+    hidl_vec<uint8_t> result(reinterpret_cast<const uint8_t*>(value.data()),
+                             reinterpret_cast<const uint8_t*>(value.data()) + value.size());
     return result;
 }
 
-inline static hidl_vec<uint8_t> blob2hidlVec(const std::vector<uint8_t>& blob,
-                                             bool inPlace = true) {
-    hidl_vec<uint8_t> result;
-    result.setToExternal(const_cast<uint8_t*>(blob.data()), static_cast<size_t>(blob.size()),
-                         !inPlace);
+inline static hidl_vec<uint8_t> blob2hidlVec(const std::vector<uint8_t>& blob) {
+    hidl_vec<uint8_t> result(blob.data(), blob.data() + static_cast<size_t>(blob.size()));
     return result;
 }
 
diff --git a/keymaster/4.0/vts/functional/Android.bp b/keymaster/4.0/vts/functional/Android.bp
index d74a16f..333e408 100644
--- a/keymaster/4.0/vts/functional/Android.bp
+++ b/keymaster/4.0/vts/functional/Android.bp
@@ -29,4 +29,5 @@
         "libkeymaster4support",
         "libsoftkeymasterdevice",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp b/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp
index 784ae30..a9c6f6c 100644
--- a/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp
+++ b/keymaster/4.0/vts/functional/keymaster_hidl_hal_test.cpp
@@ -181,7 +181,35 @@
     return d2i_X509(nullptr, &p, blob.size());
 }
 
-bool verify_chain(const hidl_vec<hidl_vec<uint8_t>>& chain) {
+bool verify_chain(const hidl_vec<hidl_vec<uint8_t>>& chain, const std::string& msg,
+                  const std::string& signature) {
+    {
+        EVP_MD_CTX md_ctx_verify;
+        X509_Ptr signing_cert(parse_cert_blob(chain[0]));
+        EVP_PKEY_Ptr signing_pubkey(X509_get_pubkey(signing_cert.get()));
+        EXPECT_TRUE(signing_pubkey);
+        ERR_print_errors_cb(
+            [](const char* str, size_t len, void* ctx) -> int {
+                (void)ctx;
+                std::cerr << std::string(str, len) << std::endl;
+                return 1;
+            },
+            nullptr);
+
+        EVP_MD_CTX_init(&md_ctx_verify);
+
+        bool result = false;
+        EXPECT_TRUE((result = EVP_DigestVerifyInit(&md_ctx_verify, NULL, EVP_sha256(), NULL,
+                                                   signing_pubkey.get())));
+        EXPECT_TRUE(
+            (result = result && EVP_DigestVerifyUpdate(&md_ctx_verify, msg.c_str(), msg.size())));
+        EXPECT_TRUE((result = result && EVP_DigestVerifyFinal(
+                                            &md_ctx_verify,
+                                            reinterpret_cast<const uint8_t*>(signature.c_str()),
+                                            signature.size())));
+        EVP_MD_CTX_cleanup(&md_ctx_verify);
+        if (!result) return false;
+    }
     for (size_t i = 0; i < chain.size(); ++i) {
         X509_Ptr key_cert(parse_cert_blob(chain[i]));
         X509_Ptr signing_cert;
@@ -3833,8 +3861,8 @@
     ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
                                              .Authorization(TAG_NO_AUTH_REQUIRED)
                                              .RsaSigningKey(2048, 65537)
-                                             .Digest(Digest::NONE)
-                                             .Padding(PaddingMode::NONE)
+                                             .Digest(Digest::SHA_2_256)
+                                             .Padding(PaddingMode::RSA_PKCS1_1_5_SIGN)
                                              .Authorization(TAG_INCLUDE_UNIQUE_ID)));
 
     hidl_vec<hidl_vec<uint8_t>> cert_chain;
@@ -3844,7 +3872,13 @@
                             .Authorization(TAG_ATTESTATION_APPLICATION_ID, HidlBuf("foo")),
                         &cert_chain));
     EXPECT_GE(cert_chain.size(), 2U);
-    EXPECT_TRUE(verify_chain(cert_chain));
+
+    string message = "12345678901234567890123456789012";
+    string signature = SignMessage(message, AuthorizationSetBuilder()
+                                                .Digest(Digest::SHA_2_256)
+                                                .Padding(PaddingMode::RSA_PKCS1_1_5_SIGN));
+
+    EXPECT_TRUE(verify_chain(cert_chain, message, signature));
     EXPECT_TRUE(verify_attestation_record("challenge", "foo",                     //
                                           key_characteristics_.softwareEnforced,  //
                                           key_characteristics_.hardwareEnforced,  //
@@ -3890,7 +3924,11 @@
                             .Authorization(TAG_ATTESTATION_APPLICATION_ID, HidlBuf("foo")),
                         &cert_chain));
     EXPECT_GE(cert_chain.size(), 2U);
-    EXPECT_TRUE(verify_chain(cert_chain));
+
+    string message(1024, 'a');
+    string signature = SignMessage(message, AuthorizationSetBuilder().Digest(Digest::SHA_2_256));
+
+    EXPECT_TRUE(verify_chain(cert_chain, message, signature));
 
     EXPECT_TRUE(verify_attestation_record("challenge", "foo",                     //
                                           key_characteristics_.softwareEnforced,  //
diff --git a/light/2.0/vts/functional/Android.bp b/light/2.0/vts/functional/Android.bp
index e0ec4cf..9f03d27 100644
--- a/light/2.0/vts/functional/Android.bp
+++ b/light/2.0/vts/functional/Android.bp
@@ -19,5 +19,6 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalLightV2_0TargetTest.cpp"],
     static_libs: ["android.hardware.light@2.0"],
+    test_suites: ["general-tests"],
 }
 
diff --git a/media/c2/1.0/Android.bp b/media/c2/1.0/Android.bp
index 3c99b6a..28829d2 100644
--- a/media/c2/1.0/Android.bp
+++ b/media/c2/1.0/Android.bp
@@ -17,11 +17,9 @@
         "IInputSurfaceConnection.hal",
     ],
     interfaces: [
-        "android.hardware.graphics.bufferqueue@2.0",
+        "android.hardware.graphics.bufferqueue@1.0",
         "android.hardware.graphics.common@1.0",
-        "android.hardware.graphics.common@1.1",
-        "android.hardware.graphics.common@1.2",
-        "android.hardware.media.bufferpool@2.0",
+        "android.hardware.media.bufferpool@1.0",
         "android.hardware.media.omx@1.0",
         "android.hardware.media@1.0",
         "android.hidl.base@1.0",
diff --git a/media/c2/1.0/IComponent.hal b/media/c2/1.0/IComponent.hal
index 822b24e..deb9255 100644
--- a/media/c2/1.0/IComponent.hal
+++ b/media/c2/1.0/IComponent.hal
@@ -16,25 +16,19 @@
 
 package android.hardware.media.c2@1.0;
 
-import android.hardware.graphics.bufferqueue@2.0::IGraphicBufferProducer;
+import android.hardware.graphics.bufferqueue@1.0::IGraphicBufferProducer;
 import android.hardware.media.omx@1.0::IGraphicBufferSource;
 
 import IConfigurable;
 import IComponentInterface;
 import IComponentListener;
-import IInputSurface;
-import IInputSurfaceConnection;
 
 /**
- * Interface for a Codec2 component corresponding to API level 1.0 or below.
- * Components have two states: stopped and running. The running state has three
- * sub-states: executing, tripped and error.
- *
- * All methods in `IComponent` must not block. If a method call cannot be
- * completed in a timely manner, it must return `TIMED_OUT` in the return
- * status.
+ * Interface for a Codec 2.0 component corresponding to API level 1.0 or
+ * below. Components have two states: stopped and running. The running
+ * state has three sub-states: executing, tripped and error.
  */
-interface IComponent {
+interface IComponent extends IComponentInterface {
 
     // METHODS AVAILABLE WHEN RUNNING
     // =========================================================================
@@ -44,42 +38,44 @@
      *
      * This method must be supported in running (including tripped) states.
      *
-     * It is acceptable for this method to return `OK` and return an error value
-     * using the IComponentListener::onWorkDone() callback.
+     * This method must return within 1ms
      *
-     * @param workBundle `WorkBundle` object containing a list of `Work` objects
-     *     to queue to the component.
+     * It is acceptable for this method to return OK and return an error value
+     * using the onWorkDone() callback.
+     *
+     * @param workBundle WorkBundle object containing Works to queue to the
+     * component.
      * @return status Status of the call, which may be
-     *   - `OK`        - Works in @p workBundle were successfully queued.
-     *   - `BAD_INDEX` - Some component id in some `Worklet` is not valid.
-     *   - `CANNOT_DO` - The components are not tunneled but some `Work` object
-     *                   contains tunneling information.
-     *   - `NO_MEMORY` - Not enough memory to queue @p workBundle.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
+     *   - OK        - Works in \p workBundle were successfully queued.
+     *   - BAD_INDEX - Some component(s) in some Work do(es) not exist.
+     *   - CANNOT_DO - The components are not tunneled.
+     *   - NO_MEMORY - Not enough memory to queue \p workBundle.
+     *   - CORRUPTED - Some unknown error prevented queuing the Works.
+     *                 (unexpected).
      */
     queue(WorkBundle workBundle) generates (Status status);
 
     /**
-     * Discards and abandons any pending `Work` items for the component.
+     * Discards and abandons any pending work for the component.
      *
      * This method must be supported in running (including tripped) states.
      *
-     * `Work` that could be immediately abandoned/discarded must be returned in
-     * @p flushedWorkBundle. The order in which queued `Work` items are
-     * discarded can be arbitrary.
+     * This method must return within 5ms.
      *
-     * `Work` that could not be abandoned or discarded immediately must be
-     * marked to be discarded at the earliest opportunity, and must be returned
-     * via IComponentListener::onWorkDone(). This must be completed within
-     * 500ms.
+     * Work that could be immediately abandoned/discarded must be returned in
+     * \p flushedWorks; this can be done in an arbitrary order.
+     *
+     * Work that could not be abandoned or discarded immediately must be marked
+     * to be discarded at the earliest opportunity, and must be returned via
+     * the onWorkDone() callback. This must be completed within 500ms.
      *
      * @return status Status of the call, which may be
-     *   - `OK`        - The component has been successfully flushed.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
-     * @return flushedWorkBundle `WorkBundle` object containing flushed `Work`
-     *     items.
+     *   - OK        - The component has been successfully flushed.
+     *   - TIMED_OUT - The flush could not be completed within the time limit.
+     *                 (unexpected)
+     *   - CORRUPTED - Some unknown error prevented flushing from
+     *                 completion. (unexpected)
+     * @return flushedWorkBundle WorkBundle object containing flushed Works.
      */
     flush(
         ) generates (
@@ -91,39 +87,42 @@
      * Drains the component, and optionally downstream components. This is a
      * signalling method; as such it does not wait for any work completion.
      *
-     * The last `Work` item is marked as "drain-till-here", so the component is
-     * notified not to wait for further `Work` before it processes what is
-     * already queued. This method can also be used to set the end-of-stream
-     * flag after `Work` has been queued. Client can continue to queue further
-     * `Work` immediately after this method returns.
+     * Marks last work item as "drain-till-here", so component is notified not
+     * to wait for further work before it processes work already queued. This
+     * method can also be used to set the end-of-stream flag after work has been
+     * queued. Client can continue to queue further work immediately after this
+     * method returns.
      *
      * This method must be supported in running (including tripped) states.
      *
-     * `Work` that is completed must be returned via
-     * IComponentListener::onWorkDone().
+     * This method must return within 1ms.
+     *
+     * Work that is completed must be returned via the onWorkDone() callback.
      *
      * @param withEos Whether to drain the component with marking end-of-stream.
      * @return status Status of the call, which may be
-     *   - `OK`        - The drain request has been successfully recorded.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
+     *   - OK        - The drain request has been successfully recorded.
+     *   - TIMED_OUT - The flush could not be completed within the time limit.
+     *                 (unexpected)
+     *   - CORRUPTED - Some unknown error prevented flushing from completion.
+     *                 (unexpected)
      */
     drain(bool withEos) generates (Status status);
 
     /**
      * Starts using a surface for output.
      *
-     * This method must not block.
-     *
-     * @param blockPoolId Id of the `C2BlockPool` to be associated with the
-     *     output surface.
-     * @param surface Output surface.
+     * @param blockPoolId The id of the BlockPool to be associated with the
+     * output surface.
+     * @param surface A surface to use for codec output.
      * @return status Status of the call, which may be
-     *   - `OK`        - The operation completed successfully.
-     *   - `CANNOT_DO` - The component does not support an output surface.
-     *   - `REFUSED`   - The output surface cannot be accessed.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
+     *   - OK        - The operation completed successfully.
+     *   - CANNOT_DO - The component does not support an output surface.
+     *   - REFUSED   - The output surface cannot be accessed.
+     *   - TIMED_OUT - The component could not be connected within the time
+     *                 limit. (unexpected)
+     *   - CORRUPTED - Some unknown error prevented connecting the component.
+     *                 (unexpected)
      */
     setOutputSurface(
             uint64_t blockPoolId,
@@ -133,101 +132,65 @@
         );
 
     /**
-     * Starts using an input surface.
+     * Starts using a persistent OMX input surface for a component.
      *
      * The component must be in running state.
      *
-     * @param inputSurface Input surface to connect to.
+     * @param producer Producer component of an OMX persistent input surface.
+     * @param source Source component of an OMX persistent input surface.
      * @return status Status of the call, which may be
-     *   - `OK`        - The operation completed successfully.
-     *   - `CANNOT_DO` - The component does not support an input surface.
-     *   - `BAD_STATE` - The component is not in running state.
-     *   - `DUPLICATE` - The component is already connected to an input surface.
-     *   - `REFUSED`   - The input surface is already in use.
-     *   - `NO_MEMORY` - Not enough memory to start the component.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
-     * @return connection `IInputSurfaceConnection` object, which can be used to
-     *     query and configure properties of the connection. This cannot be
-     *     null.
-     */
-    connectToInputSurface(
-            IInputSurface inputSurface
-        ) generates (
-            Status status,
-            IInputSurfaceConnection connection
-        );
-
-    /**
-     * Starts using an OMX input surface.
-     *
-     * The component must be in running state.
-     *
-     * This method is similar to connectToInputSurface(), but it takes an OMX
-     * input surface (as a pair of `IGraphicBufferProducer` and
-     * `IGraphicBufferSource`) instead of Codec2's own `IInputSurface`.
-     *
-     * @param producer Producer component of an OMX input surface.
-     * @param source Source component of an OMX input surface.
-     * @return status Status of the call, which may be
-     *   - `OK`        - The operation completed successfully.
-     *   - `CANNOT_DO` - The component does not support an OMX input surface.
-     *   - `BAD_STATE` - The component is not in running state.
-     *   - `DUPLICATE` - The component is already connected to an input surface.
-     *   - `REFUSED`   - The input surface is already in use.
-     *   - `NO_MEMORY` - Not enough memory to start the component.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
-     * @return connection `IInputSurfaceConnection` object, which can be used to
-     *     query and configure properties of the connection. This cannot be
-     *     null.
+     *   - OK        - The operation completed successfully.
+     *   - CANNOT_DO - The component does not support an input surface.
+     *   - BAD_STATE - Component is not in running state.
+     *   - DUPLICATE - The component is already connected to an input surface.
+     *   - REFUSED   - The input surface is already in use.
+     *   - NO_MEMORY - Not enough memory to start the component.
+     *   - TIMED_OUT - The component could not be connected within the time
+     *                 limit. (unexpected)
+     *   - CORRUPTED - Some unknown error prevented connecting the component.
+     *                 (unexpected)
      */
     connectToOmxInputSurface(
             IGraphicBufferProducer producer,
             IGraphicBufferSource source
-        ) generates (
-            Status status,
-            IInputSurfaceConnection connection
-        );
+        ) generates (Status status);
 
     /**
      * Stops using an input surface.
      *
+     * This call is used for both Codec 2.0 and OMX input surfaces.
+     *
      * The component must be in running state.
      *
      * @return status Status of the call, which may be
-     *   - `OK`        - The operation completed successfully.
-     *   - `CANNOT_DO` - The component does not support an input surface.
-     *   - `BAD_STATE` - The component is not in running state.
-     *   - `NOT_FOUND` - The component is not connected to an input surface.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
+     *   - OK        - The operation completed successfully.
+     *   - CANNOT_DO - The component does not support an input surface.
+     *   - BAD_STATE - Component is not in running state.
+     *   - NOT_FOUND - The component is not connected to an input surface.
+     *   - TIMED_OUT - The component could not be connected within the time
+     *                 limit. (unexpected)
+     *   - CORRUPTED - Some unknown error prevented connecting the component.
+     *                 (unexpected)
      */
     disconnectFromInputSurface() generates (Status Status);
 
     /**
-     * Creates a local `C2BlockPool` backed by the given allocator and returns
-     * its id.
+     * Creates a local block pool backed by the given allocator and returns its
+     * identifier.
      *
-     * The returned @p blockPoolId is the only way the client can refer to a
-     * `C2BlockPool` object in the component. The id can be passed to
-     * setOutputSurface() or used in some C2Param objects later.
+     * This call must return within 100 msec.
      *
-     * The created `C2BlockPool` object can be destroyed by calling
-     * destroyBlockPool(), reset() or release(). reset() and release() must
-     * destroy all `C2BlockPool` objects that have been created.
-     *
-     * @param allocatorId Id of a `C2Allocator`.
+     * @param allocatorId The Codec 2.0 allocator ID
      * @return status Status of the call, which may be
-     *   - `OK`        - The operation completed successfully.
-     *   - `NO_MEMORY` - Not enough memory to create the pool.
-     *   - `BAD_VALUE` - @p allocatorId is not recognized.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
-     * @return blockPoolId Id of the created C2BlockPool object. This may be
-     *     used in setOutputSurface() if the allocator
-     * @return configurable Configuration interface for the created pool. This
-     *     must not be null.
+     *   - OK        - The operation completed successfully.
+     *   - NO_MEMORY - Not enough memory to create the pool.
+     *   - BAD_VALUE - Invalid allocator.
+     *   - TIMED_OUT - The pool could not be created within the time
+     *                 limit. (unexpected)
+     *   - CORRUPTED - Some unknown error prevented creating the pool.
+     *                 (unexpected)
+     * @return blockPoolId The Codec 2.0 blockpool ID for the created pool.
+     * @return configurable Configuration interface for the created pool.
      */
     createBlockPool(uint32_t allocatorId) generates (
         Status status,
@@ -238,13 +201,17 @@
     /**
      * Destroys a local block pool previously created by createBlockPool().
      *
-     * @param blockPoolId Id of a `C2BlockPool` that was previously returned by
+     * This call must return within 100 msec.
+     *
+     * @param blockPoolId The block pool id previously returned by
      *      createBlockPool().
      * @return status Status of the call, which may be
-     *   - `OK`        - The operation completed successfully.
-     *   - `NOT_FOUND` - The supplied blockPoolId is not valid.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
+     *   - OK        - The operation completed successfully.
+     *   - NOT_FOUND - The supplied blockPoolId is not valid.
+     *   - TIMED_OUT - The pool could not be destroyedwithin the time limit.
+     *                 (unexpected)
+     *   - CORRUPTED - Some unknown error prevented destruction of the pool.
+     *                 (unexpected)
      */
     destroyBlockPool(uint64_t blockPoolId) generates (Status status);
 
@@ -256,24 +223,28 @@
      *
      * This method must be supported in stopped state as well as tripped state.
      *
-     * If the return value is `OK`, the component must be in the running state.
-     * If the return value is `BAD_STATE` or `DUPLICATE`, no state change is
-     * expected as a response to this call. Otherwise, the component must be in
-     * the stopped state.
+     * If the return value is OK, the component must be in the running state.
+     * If the return value is BAD_STATE or DUPLICATE, no state change is
+     * expected as a response to this call.
+     * Otherwise, the component must be in the stopped state.
      *
      * If a component is in the tripped state and start() is called while the
-     * component configuration still results in a trip, start() must succeed and
-     * a new onTripped() callback must be used to communicate the configuration
+     * component configuration still results in a trip, start must succeed and
+     * a new onTripped callback must be used to communicate the configuration
      * conflict that results in the new trip.
      *
+     * This method must return within 500ms.
+     *
      * @return status Status of the call, which may be
-     *   - `OK`        - The component has started successfully.
-     *   - `BAD_STATE` - Component is not in stopped or tripped state.
-     *   - `DUPLICATE` - When called during another start call from another
-     *                   thread.
-     *   - `NO_MEMORY` - Not enough memory to start the component.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
+     *   - OK        - The component has started successfully.
+     *   - BAD_STATE - Component is not in stopped or tripped state.
+     *   - DUPLICATE - When called during another start call from another
+     *                 thread.
+     *   - NO_MEMORY - Not enough memory to start the component.
+     *   - TIMED_OUT - The component could not be started within the time limit.
+     *                 (unexpected)
+     *   - CORRUPTED - Some unknown error prevented starting the component.
+     *                 (unexpected)
      */
     start() generates (Status status);
 
@@ -284,22 +255,22 @@
      *
      * This method must return withing 500ms.
      *
-     * Upon this call, all pending `Work` must be abandoned.
-     *
-     * If the return value is `BAD_STATE` or `DUPLICATE`, no state change is
-     * expected as a response to this call. For all other return values, the
-     * component must be in the stopped state.
+     * Upon this call, all pending work must be abandoned.
+     * If the return value is BAD_STATE or DUPLICATE, no state change is
+     * expected as a response to this call.
+     * For all other return values, the component must be in the stopped state.
      *
      * This does not alter any settings and tunings that may have resulted in a
      * tripped state.
      *
      * @return status Status of the call, which may be
-     *   - `OK`        - The component has stopped successfully.
-     *   - `BAD_STATE` - Component is not in running state.
-     *   - `DUPLICATE` - When called during another stop call from another
-     *                   thread.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
+     *   - OK        - The component has stopped successfully.
+     *   - BAD_STATE - Component is not in running state.
+     *   - DUPLICATE - When called during another stop call from another thread.
+     *   - TIMED_OUT - The component could not be stopped within the time limit.
+     *                 (unexpected)
+     *   - CORRUPTED - Some unknown error prevented starting the component.
+     *                 (unexpected)
      */
     stop() generates (Status status);
 
@@ -313,24 +284,25 @@
      *
      * This method must return withing 500ms.
      *
-     * When this call returns, if @p status is `OK`, all `Work` items must
-     * have been abandoned, and all resources (including `C2BlockPool` objects
-     * previously created by createBlockPool()) must have been released.
+     * After this call returns all work must have been abandoned, all references
+     * must have been released.
      *
-     * If the return value is `BAD_STATE` or `DUPLICATE`, no state change is
-     * expected as a response to this call. For all other return values, the
-     * component must be in the stopped state.
+     * If the return value is BAD_STATE or DUPLICATE, no state change is
+     * expected as a response to this call.
+     * For all other return values, the component shall be in the stopped state.
      *
-     * This brings settings back to their default, "guaranteeing" no tripped
+     * This brings settings back to their default - "guaranteeing" no tripped
      * state.
      *
      * @return status Status of the call, which may be
-     *   - `OK`        - The component has been reset.
-     *   - `BAD_STATE` - Component is in released state.
-     *   - `DUPLICATE` - When called during another reset call from another
-     *                   thread.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
+     *   - OK        - The component has been reset.
+     *   - BAD_STATE - Component is in released state.
+     *   - DUPLICATE - When called during another reset call from another
+     *                 thread.
+     *   - TIMED_OUT - The component could not be reset within the time limit.
+     *                 (unexpected)
+     *   - CORRUPTED - Some unknown error prevented resetting the component.
+     *                 (unexpected)
      */
     reset() generates (Status status);
 
@@ -339,27 +311,19 @@
      *
      * This method must be supported in stopped state.
      *
-     * This method destroys the component. Upon return, if @p status is `OK` or
-     * `DUPLICATE`, all resources must have been released.
+     * This method must return withing 500ms. Upon return all references must
+     * be abandoned.
      *
      * @return status Status of the call, which may be
-     *   - `OK`        - The component has been released.
-     *   - `BAD_STATE` - The component is running.
-     *   - `DUPLICATE` - The component is already released.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
+     *   - OK        - The component has been released.
+     *   - BAD_STATE - The component is running.
+     *   - DUPLICATE - The component is already released.
+     *   - TIMED_OUT - The component could not be released within the time
+     *                 limit. (unexpected)
+     *   - CORRUPTED - Some unknown error prevented releasing the component.
+     *                 (unexpected)
      */
     release() generates (Status status);
 
-    /**
-     * Returns the @ref IComponentInterface instance associated to this
-     * component.
-     *
-     * An @p IConfigurable instance for the component can be obtained by calling
-     * IComponentInterface::getConfigurable() on the returned @p intf.
-     *
-     * @return intf `IComponentInterface` instance. This must not be null.
-     */
-    getInterface() generates (IComponentInterface intf);
 };
 
diff --git a/media/c2/1.0/IComponentInterface.hal b/media/c2/1.0/IComponentInterface.hal
index a007d02..d4b30b1 100644
--- a/media/c2/1.0/IComponentInterface.hal
+++ b/media/c2/1.0/IComponentInterface.hal
@@ -19,20 +19,21 @@
 import IConfigurable;
 
 /**
- * Component interface object. This object contains all of the configurations of
+ * Component interface object. This object contains all of the configuration of
  * a potential or actual component. It can be created and used independently of
- * an actual Codec2 component to query supported parameters for various
- * component settings, and configurations for a potential component.
- *
- * An actual component exposes this interface via IComponent::getInterface().
+ * an actual Codec 2.0 component instance to query support and parameters for
+ * various component settings and configurations for a potential component.
+ * Actual components also expose this interface.
  */
-interface IComponentInterface {
-    /**
-     * Returns the @ref IConfigurable instance associated to this component
-     * interface.
+interface IComponentInterface extends IConfigurable {
+    /*
+     * There are no additional methods to IConfigurable interface.
      *
-     * @return configurable `IConfigurable` instance. This must not be null.
+     * Component interfaces have no states.
+     *
+     * The name of the component or component interface object is a unique name
+     * for that component or component interface 'class'; however, multiple
+     * instances of that component must have the same name.
      */
-    getConfigurable() generates (IConfigurable configurable);
 };
 
diff --git a/media/c2/1.0/IComponentListener.hal b/media/c2/1.0/IComponentListener.hal
index 70d5fb2..eb71ecb 100644
--- a/media/c2/1.0/IComponentListener.hal
+++ b/media/c2/1.0/IComponentListener.hal
@@ -17,112 +17,54 @@
 package android.hardware.media.c2@1.0;
 
 /**
- * Callback interface for handling notifications from @ref IComponent.
+ * This callback interface is used for handling notifications from IComponent.
  */
 interface IComponentListener {
 
     /**
-     * Notify the listener that some `Work` items have been completed.
-     *
-     * All the input buffers in the returned `Work` objects must not be used by
-     * the component after onWorkDone() is called.
-     *
-     * @param workBundle List of completed `Work` objects.
+     * Notify the listener that some works have been completed.
      */
     oneway onWorkDone(WorkBundle workBundle);
 
     /**
      * Notify the listener that the component is tripped.
-     *
-     * @param settingResults List of failures.
      */
     oneway onTripped(vec<SettingResult> settingResults);
 
     /**
      * Notify the listener of an error.
      *
-     * @param status Error type. @p status may be `OK`, which means that an
-     *     error has occurred, but the error type does not fit into the type
-     *     `Status`. In this case, additional information is provided by
-     *     @p errorCode.
-     * @param errorCode Additional error information. The framework may not
-     *     recognize the meaning of this value.
+     * @param status Error type. \p status may be `OK`, which means that an
+     *     error has occurred, but the error type is unknown.
+     * @param errorCode Additional error code. The framework may not recognize
+     *     this.
      */
     oneway onError(Status status, uint32_t errorCode);
 
     /**
-     * Information about rendering of a frame to a `Surface`.
+     * Information about rendering of a frame.
      */
     struct RenderedFrame {
         /**
-         * Id of the `BufferQueue` containing the rendered buffer.
-         *
-         * This value must have been obtained by an earlier call to
-         * IGraphicBufferProducer::getUniqueId().
+         * Id of the buffer queue containing the rendered buffer.
          */
         uint64_t bufferQueueId;
         /**
          * Id of the slot of the rendered buffer.
-         *
-         * This value must have been obtained by an earlier call to
-         * IGraphicBufferProducer::dequeueBuffer() or
-         * IGraphicBufferProducer::attachBuffer().
          */
         int32_t slotId;
         /**
-         * Timestamp the rendering happened.
-         *
-         * The reference point for the timestamp is determined by the
-         * `BufferQueue` that performed the rendering.
+         * Timestamp of the rendering (consistent with timestamps in
+         * the associated BufferQueue).
          */
         int64_t timestampNs;
     };
 
     /**
-     * Notify the listener that frames have been rendered.
+     * Notify the listener that frames are rendered.
      *
-     * @param renderedFrames List of @ref RenderedFrame objects.
+     * @param renderedFrames List of information about renderings of frames.
      */
     oneway onFramesRendered(vec<RenderedFrame> renderedFrames);
-
-    /**
-     * Identifying information for an input buffer previously queued to the
-     * component via IComponent::queue().
-     */
-    struct InputBuffer {
-        /**
-         * This value comes from `Work::input.ordinal.frameIndex` in a `Work`
-         * object that was previously queued.
-         */
-        uint64_t frameIndex;
-        /**
-         * This value is an index into `Work::input.buffers` (which is an array)
-         * in a `Work` object that was previously queued.
-         */
-        uint32_t arrayIndex;
-    };
-
-    /**
-     * Notify the listener that some input buffers are no longer needed by the
-     * component, and hence can be released or reused by the client.
-     *
-     * Input buffers that are contained in a `Work` object returned by an
-     * earlier onWorkDone() call are assumed released, so they must not appear
-     * in any onInputBuffersReleased() calls. That means
-     * onInputBuffersReleased() must only report input buffers that are released
-     * before the output in the same `Work` item is produced. However, it is
-     * possible for an input buffer to be returned by onWorkDone() after it has
-     * been reported by onInputBuffersReleased().
-     *
-     * @note onWorkDone() and onInputBuffersReleased() both notify the client
-     * that input buffers are no longer needed. However, in order to minimize
-     * IPC calls, onInputBuffersReleased() should be called only when
-     * onWorkDone() cannot be called, e.g., the component needs more input
-     * before an output can be produced.
-     *
-     * @param inputBuffers List of `InputBuffer` objects, identifying input
-     * buffers that are no longer needed by the component.
-     */
-    oneway onInputBuffersReleased(vec<InputBuffer> inputBuffers);
 };
 
diff --git a/media/c2/1.0/IComponentStore.hal b/media/c2/1.0/IComponentStore.hal
index 6a57c38..d2474cc 100644
--- a/media/c2/1.0/IComponentStore.hal
+++ b/media/c2/1.0/IComponentStore.hal
@@ -16,40 +16,34 @@
 
 package android.hardware.media.c2@1.0;
 
-import android.hardware.media.bufferpool@2.0::IClientManager;
+import android.hardware.media.bufferpool@1.0::IClientManager;
 import IComponentInterface;
 import IComponentListener;
 import IComponent;
 import IConfigurable;
 import IInputSurface;
 
-/**
- * Entry point for Codec2 HAL.
- *
- * All methods in `IComponentStore` must not block. If a method call cannot be
- * completed in a timely manner, it must return `TIMED_OUT` in the return
- * status. The only exceptions are getPoolClientManager() and getConfigurable(),
- * which must always return immediately.
- */
-interface IComponentStore {
+interface IComponentStore extends IConfigurable {
 
     /**
      * Creates a component by name.
      *
-     * @param name Name of the component to create. This must match one of the
-     *     names returned by listComponents().
-     * @param listener Callback receiver.
-     * @param pool `IClientManager` object of the BufferPool in the client
-     *     process. This may be null if the client does not own a BufferPool.
-     * @return status Status of the call, which may be
-     *   - `OK`        - The component was created successfully.
-     *   - `NOT_FOUND` - There is no component with the given name.
-     *   - `NO_MEMORY` - Not enough memory to create the component.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
-     * @return comp The created component if @p status is `OK`.
+     * This method must return within 100ms.
      *
-     * @sa IComponentListener.
+     * @param name Name of the component to create. This should match one of the
+     *     names returned by listComponents().
+     * @param listener The component listener to use for the component.
+     * @param pool The buffer pool client manager of the component listener.
+     *     This must be null if the listener process does not own a buffer pool.
+     * @return status Status of the call, which may be
+     *   - OK        - The component was created successfully.
+     *   - NOT_FOUND - There is no component with the given name.
+     *   - NO_MEMORY - Not enough memory to create the component.
+     *   - TIMED_OUT - The component could not be created within the time limit.
+     *                 (unexpected)
+     *   - CORRUPTED - Some unknown error prevented the creation of the
+     *                 component. (unexpected)
+     * @return comp The created component if `Status = OK`.
      */
     createComponent(
             string name,
@@ -63,15 +57,19 @@
     /**
      * Creates a component interface by name.
      *
+     * This method must return within 100ms.
+     *
      * @param name Name of the component interface to create. This should match
      *     one of the names returned by listComponents().
      * @return status Status of the call, which may be
-     *   - `OK         - The component interface was created successfully.
-     *   - `NOT_FOUND` - There is no component interface with the given name.
-     *   - `NO_MEMORY` - Not enough memory to create the component interface.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
-     * @return compIntf The created component interface if @p status is `OK`.
+     *   - OK        - The component interface was created successfully.
+     *   - NOT_FOUND - There is no component interface with the given name.
+     *   - NO_MEMORY - Not enough memory to create the component interface.
+     *   - TIMED_OUT - The component interface could not be created within the
+     *                 time limit. (unexpected)
+     *   - CORRUPTED - Some unknown error prevented the creation of the
+     *                 component interface. (unexpected)
+     * @return compIntf The created component interface if `Status = OK`.
      */
     createInterface(
             string name
@@ -85,49 +83,57 @@
      */
     struct ComponentTraits {
         /**
-         * Name of the component. This must be unique for each component.
-         *
-         * This name is use to identify the component to create in
-         * createComponent() and createComponentInterface().
+         * Name of the component.
          */
         string name;
 
         enum Domain : uint32_t {
-            OTHER = 0,
-            VIDEO,
             AUDIO,
-            IMAGE,
+            VIDEO,
+            OTHER = 0xffffffff,
         };
         /**
-         * Component domain.
+         * Component domain. The framework may not recognize `OTHER`.
          */
         Domain domain;
+        /**
+         * If #domain is `OTHER`, #domainOther can be used to provide additional
+         * information. Otherwise, #domainOther is ignored. The framework may
+         * not inspect this value.
+         */
+        uint32_t domainOther;
 
         enum Kind : uint32_t {
-            OTHER = 0,
             DECODER,
             ENCODER,
+            OTHER = 0xffffffff,
         };
         /**
-         * Component kind.
+         * Component kind. The framework may not recognize `OTHER`.
          */
         Kind kind;
+        /**
+         * If #kind is `OTHER`, #kindOther can be used to provide additional
+         * information. Otherwise, #kindOther is ignored. The framework may not
+         * inspect this value.
+         */
+        uint32_t kindOther;
 
         /**
-         * Rank used by `MediaCodecList` to determine component ordering. Lower
+         * Rank used by MediaCodecList to determine component ordering. Lower
          * value means higher priority.
          */
         uint32_t rank;
 
         /**
-         * MIME type.
+         * Media type.
          */
         string mediaType;
 
         /**
          * Aliases for component name for backward compatibility.
          *
-         * Multiple components can have the same alias (but not the same
+         * \note Multiple components can have the same alias (but not the same
          * component name) as long as their media types differ.
          */
         vec<string> aliases;
@@ -136,51 +142,36 @@
     /**
      * Returns the list of components supported by this component store.
      *
-     * @return status Status of the call, which may be
-     *   - `OK         - The operation was successful.
-     *   - `NO_MEMORY` - Not enough memory to complete this method.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
-     * @return traits List of component traits for all components supported by
-     *     this store (in no particular order).
+     * This method must return within 500ms.
+     *
+     * @return traits List of component traits for all components supported by this store in no
+     * particular order.
      */
-    listComponents() generates (
-            Status status,
-            vec<ComponentTraits> traits
-        );
+    listComponents() generates (vec<ComponentTraits> traits);
 
     /**
      * Creates a persistent input surface that can be used as an input surface
      * for any IComponent instance
      *
-     * @return status Status of the call, which may be
-     *   - `OK         - The operation was successful.
-     *   - `NO_MEMORY` - Not enough memory to complete this method.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
-     * @return surface A persistent input surface. This may be null to indicate
-     *     an error.
+     * This method must return within 100ms.
+     *
+     * @return surface A persistent input surface
      */
-    createInputSurface() generates (
-            Status status,
-            IInputSurface surface
-        );
+    createInputSurface() generates (IInputSurface surface);
 
     /**
-     * Returns a list of `StructDescriptor` objects for a set of requested
-     * C2Param structure indices that this store is aware of.
+     * Returns a list of StructDescriptor object for a set of requested
+     * structures that this store is aware of.
      *
      * This operation must be performed at best effort, e.g. the component
      * store must simply ignore all struct indices that it is not aware of.
      *
-     * @param indices Indices of C2Param structures to describe.
+     * @param indices struct indices to return des
      * @return status Status of the call, which may be
-     *   - `OK`        - The operation completed successfully.
-     *   - `NOT_FOUND` - Some indices were not known.
-     *   - `NO_MEMORY` - Not enough memory to complete this method.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
-     * @return structs List of `StructDescriptor` objects.
+     *   - OK        - The operation completed successfully.
+     *   - NOT_FOUND - Some indices were not known.
+     *   - NO_MEMORY - Not enough memory to complete this method.
+     * @return structs List of StructDescriptor objects.
      */
     getStructDescriptors(
             vec<ParamIndex> indices
@@ -190,35 +181,33 @@
         );
 
     /**
-     * Copies the contents of @p src into @p dst without changing the format of
-     * @p dst.
+     * Returns information required for using BufferPool API in buffer passing.
+     * If the returned pool is not null, the client can call registerSender() to
+     * register its IAccessor instance, hence allowing the client to send
+     * buffers to components hosted by this process.
+     *
+     * @return pool If the component store supports receiving buffers via
+     *     BufferPool API, \p pool must be a valid `IClientManager` instance.
+     *     Otherwise, \p pool must be null.
+     */
+    getPoolClientManager(
+        ) generates (
+            IClientManager pool
+        );
+
+    /**
+     * The store must copy the contents of \p src into \p dst without changing
+     * the format of \p dst.
      *
      * @param src Source buffer.
      * @param dst Destination buffer.
      * @return status Status of the call, which may be
-     *   - `OK`        - The copy is successful.
-     *   - `CANNOT_DO` - @p src and @p dst are not compatible.
-     *   - `REFUSED`   - No permission to copy.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
+     *   - OK        - The copy is successful.
+     *   - CANNOT_DO - \p src and \p dst are not compatible.
+     *   - REFUSED   - No permission to copy.
+     *   - CORRUPTED - The copy cannot be done. (unexpected)
      */
     copyBuffer(Buffer src, Buffer dst) generates (Status status);
 
-    /**
-     * Returns the `IClientManager` object for the component's BufferPool.
-     *
-     * @return pool If the component store supports receiving buffers via
-     *     BufferPool API, @p pool must be a valid `IClientManager` instance.
-     *     Otherwise, @p pool must be null.
-     */
-    getPoolClientManager() generates (IClientManager pool);
-
-    /**
-     * Returns the @ref IConfigurable instance associated to this component
-     * store.
-     *
-     * @return configurable `IConfigurable` instance. This must not be null.
-     */
-    getConfigurable() generates (IConfigurable configurable);
 };
 
diff --git a/media/c2/1.0/IConfigurable.hal b/media/c2/1.0/IConfigurable.hal
index 31dc4d3..cd4dd10 100644
--- a/media/c2/1.0/IConfigurable.hal
+++ b/media/c2/1.0/IConfigurable.hal
@@ -17,78 +17,43 @@
 package android.hardware.media.c2@1.0;
 
 /**
- * Generic configuration interface presented by all configurable Codec2 objects.
+ * Generic configuration interface used by all configurable Codec 2.0
+ * components.
  *
- * This interface must be supported in all states of the owning object, and must
- * not change the state of the owning object.
+ * This interface must be supported in all states of the inheriting
+ * object, and must not change the state of the inheriting object.
  */
 interface IConfigurable {
     /**
-     * Returns the id of the object. This must be unique among all objects of
-     * the same type hosted by the same store.
+     * Returns the name of this object. This must match the name that was
+     * supplied during the creation of the object.
      *
-     * @return id Id of the object.
-     */
-    getId() generates (uint32_t id);
-
-    /**
-     * Returns the name of the object.
-     *
-     * This must match the name that was supplied during the creation of the
-     * object.
-     *
-     * @return name Name of the object.
+     * @return name Name of this object.
      */
     getName() generates (string name);
 
     /**
-     * Queries a set of parameters from the object.
+     * Queries a set of parameters from the object. Querying is performed at
+     * best effort: the object must query all supported parameters and skip
+     * unsupported ones, or parameters that could not be allocated. Any errors
+     * are communicated in the return value.
      *
-     * Querying is performed at best effort: the object must query all supported
-     * parameters and skip unsupported ones (which may include parameters that
-     * could not be allocated). Any errors are communicated in the return value.
+     * \note Parameter values do not depend on the order of query.
      *
-     * If @p mayBlock is false, this method must not block. All parameter
-     * queries that require blocking must be skipped.
+     * This method must return within 1ms if \p mayBlock is DONT_BLOCK, and
+     * within 5ms otherwise.
      *
-     * If @p mayBlock is true, a query may block, but the whole method call
-     * has to complete in a timely manner, or `status = TIMED_OUT` is returned.
-     *
-     * If @p mayBlock is false, this method must not block. Otherwise, this
-     * method is allowed to block for a certain period of time before completing
-     * the operation. If the operation is not completed in a timely manner,
-     * `status = TIMED_OUT` is returned.
-     *
-     * @note The order of C2Param objects in @p param does not depend on the
-     *     order of C2Param structure indices in @p indices.
-     *
-     * \par For IComponent
-     *
-     * When the object type is @ref IComponent, this method must be supported in
-     * any state except released. This call must not change the state nor the
-     * internal configuration of the component.
-     *
-     * The blocking behavior of this method differs among states:
-     *   - In the stopped state, this must be non-blocking. @p mayBlock is
-     *     ignored. (The method operates as if @p mayBlock was false.)
-     *   - In any of the running states, this method may block momentarily if
-     *     @p mayBlock is true. However, if the call cannot be completed in a
-     *     timely manner, `status = TIMED_OUT` is returned.
-     *
-     * @param indices List of C2Param structure indices to query.
+     * @param indices List of param indices for params to be queried.
      * @param mayBlock Whether this call may block or not.
      * @return status Status of the call, which may be
-     *   - `OK`        - All parameters could be queried.
-     *   - `BAD_INDEX` - All supported parameters could be queried, but some
-     *                   parameters were not supported.
-     *   - `NO_MEMORY` - Could not allocate memory for a supported parameter.
-     *   - `BLOCKING`  - Querying some parameters requires blocking, but
-     *                   @p mayBlock is false.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
-     * @return params Flattened representation of C2Param objects.
-     *
-     * @sa Params.
+     *   - OK        - All parameters could be queried.
+     *   - BAD_INDEX - All supported parameters could be queried, but some
+     *                 parameters were not supported.
+     *   - NO_MEMORY - Could not allocate memory for a supported parameter.
+     *   - BLOCKING  - Querying some parameters requires blocking.
+     *   - CORRUPTED - Some unknown error prevented the querying of the
+     *                 parameters. (unexpected)
+     * @return params List of params queried corresponding to \p indices.
      */
     query(
             vec<ParamIndex> indices,
@@ -99,60 +64,31 @@
         );
 
     /**
-     * Sets a set of parameters for the object.
+     * Sets a set of parameters for the object. Tuning is performed at best
+     * effort: the object must update all supported configuration at best
+     * effort and skip unsupported parameters. Any errors are communicated in
+     * the return value and in \p failures.
      *
-     * Tuning is performed at best effort: the object must update all supported
-     * configurations at best effort and skip unsupported parameters. Any errors
-     * are communicated in the return value and in @p failures.
+     * \note Parameter tuning DOES depend on the order of the tuning parameters.
+     * E.g. some parameter update may allow some subsequent parameter update.
      *
-     * A non-strict parameter update with an unsupported value shall cause an
-     * update to the closest supported value. A strict parameter update with an
-     * unsupported value shall be skipped and a failure shall be returned.
-     *
-     * If @p mayBlock is false, this method must not block. An update that
-     * requires blocking shall be skipped and a failure shall be returned.
-     *
-     * If @p mayBlock is true, an update may block, but the whole method call
-     * has to complete in a timely manner, or `status = TIMED_OUT` is returned.
-     *
-     * The final values for all parameters set are propagated back to the caller
-     * in @p params.
-     *
-     * \par For IComponent
-     *
-     * When the object type is @ref IComponent, this method must be supported in
-     * any state except released.
-     *
-     * The blocking behavior of this method differs among states:
-     *   - In the stopped state, this must be non-blocking. @p mayBlock is
-     *     ignored. (The method operates as if @p mayBlock was false.)
-     *   - In any of the running states, this method may block momentarily if
-     *     @p mayBlock is true. However, if the call cannot be completed in a
-     *     timely manner, `status = TIMED_OUT` is returned.
-     *
-     * @note Parameter tuning @e does depend on the order of the tuning
-     * parameters, e.g., some parameter update may enable some subsequent
-     * parameter update.
+     * This method must return within 1ms if \p mayBlock is false, and within
+     * 5ms otherwise.
      *
      * @param inParams Requested parameter updates.
      * @param mayBlock Whether this call may block or not.
      * @return status Status of the call, which may be
-     *   - `OK`        - All parameters could be updated successfully.
-     *   - `BAD_INDEX` - All supported parameters could be updated successfully,
-     *                   but some parameters were not supported.
-     *   - `NO_MEMORY` - Some supported parameters could not be updated
-     *                   successfully because they contained unsupported values.
-     *                   These are returned in @p failures.
-     *   - `BLOCKING`  - Setting some parameters requires blocking, but
-     *                   @p mayBlock is false.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
-     * @return failures List of update failures.
-     * @return outParams Flattened representation of configured parameters. The
-     *     order of parameters in @p outParams is based on the order of
-     *     requested updates in @p inParams.
-     *
-     * @sa SettingResult.
+     *   - OK        - All parameters could be updated successfully.
+     *   - BAD_INDEX - All supported parameters could be updated successfully,
+     *                 but some parameters were not supported.
+     *   - NO_MEMORY - Some supported parameters could not be updated
+     *                 successfully because they contained unsupported values.
+     *                 These are returned in \p failures.
+     *   - BLOCKING  - Setting some parameters requires blocking.
+     *   - CORRUPTED - Some unknown error prevented the update of the
+     *                 parameters. (unexpected)
+     * @return failures List of parameter failures.
+     * @return outParams Resulting values for the configured parameters.
      */
     config(
             Params inParams,
@@ -167,19 +103,22 @@
     // =========================================================================
 
     /**
-     * Returns a list of supported parameters within a selected range of C2Param
-     * structure indices.
+     * Returns a selected range of the set of supported parameters.
      *
-     * @param start The first index of the selected range.
-     * @param count The length of the selected range.
+     * The set of supported parameters are represented in a vector with a
+     * start index of 0, and the selected range are indices into this vector.
+     * Fewer than \p count parameters are returned if the selected range is
+     * not fully/not at all part of the available vector indices.
+     *
+     * This method must return within 1ms.
+     *
+     * @param start start index of selected range
+     * @param count size of the selected
      * @return status Status of the call, which may be
-     *   - `OK`        - The operation completed successfully.
-     *   - `NO_MEMORY` - Not enough memory to complete this method.
-     * @return params List of supported parameters in the selected range. This
-     *     list may have fewer than @p count elements if some indices in the
-     *     range are not supported.
-     *
-     * @sa ParamDescriptor.
+     *   - OK        - The operation completed successfully.
+     *   - NO_MEMORY - Not enough memory to complete this method.
+     * @return params Vector containing the selected range of supported
+     *     parameters.
      */
     querySupportedParams(
             uint32_t start,
@@ -192,42 +131,23 @@
     /**
      * Retrieves the supported values for the queried fields.
      *
-     * The object must process all fields queried even if some queries fail.
+     * Upon return the object must fill in the supported
+     * values for the fields listed as well as a status for each field.
+     * Object shall process all fields queried even if some queries fail.
      *
-     * If @p mayBlock is false, this method must not block. Otherwise, this
-     * method is allowed to block for a certain period of time before completing
-     * the operation. If the operation cannot be completed in a timely manner,
-     * `status = TIMED_OUT` is returned.
+     * This method must return within 1ms if \p mayBlock is false, and within
+     * 5ms otherwise.
      *
-     * \par For IComponent
-     *
-     * When the object type is @ref IComponent, this method must be supported in
-     * any state except released.
-     *
-     * The blocking behavior of this method differs among states:
-     *   - In the stopped state, this must be non-blocking. @p mayBlock is
-     *     ignored. (The method operates as if @p mayBlock was false.)
-     *   - In any of the running states, this method may block momentarily if
-     *     @p mayBlock is true. However, if the call cannot be completed in a
-     *     timely manner, `status = TIMED_OUT` is returned.
-     *
-     * @param inFields List of field queries.
+     * @param inFields Vector of field queries.
      * @param mayBlock Whether this call may block or not.
      * @return status Status of the call, which may be
-     *   - `OK`        - The operation completed successfully.
-     *   - `BLOCKING`  - Querying some parameters requires blocking, but
-     *                   @p mayBlock is false.
-     *   - `NO_MEMORY` - Not enough memory to complete this method.
-     *   - `BAD_INDEX` - At least one field was not recognized as a component
-     *                   field.
-     *   - `BLOCKING`  - Querying some fields requires blocking, but @p mayblock
-     *                   is false.
-     *   - `TIMED_OUT` - The operation cannot be finished in a timely manner.
-     *   - `CORRUPTED` - Some unknown error occurred.
-     * @return outFields List of supported values and results for the
-     *     supplied queries.
-     *
-     * @sa FieldSupportedValuesQuery, FieldSupportedValuesQueryResult.
+     *   - OK        - The operation completed successfully.
+     *   - BLOCKING  - Querying some parameters requires blocking.
+     *   - NO_MEMORY - Not enough memory to complete this method.
+     *   - BAD_INDEX - At least one field was not recognized as a component
+     *                 field.
+     * @return outFields Vector containing supported values and query result
+     *     for the selected fields.
      */
     querySupportedValues(
             vec<FieldSupportedValuesQuery> inFields,
diff --git a/media/c2/1.0/IInputSurface.hal b/media/c2/1.0/IInputSurface.hal
index 0a1b56d..c083a21 100644
--- a/media/c2/1.0/IInputSurface.hal
+++ b/media/c2/1.0/IInputSurface.hal
@@ -16,36 +16,46 @@
 
 package android.hardware.media.c2@1.0;
 
-import android.hardware.graphics.bufferqueue@2.0::IGraphicBufferProducer;
+import android.hardware.graphics.bufferqueue@1.0::IGraphicBufferProducer;
 
 import IConfigurable;
+import IComponent;
+import IInputSurfaceConnection;
 
 /**
- * Input surface for a Codec2 component.
- *
- * An <em>input surface</em> is an instance of `IInputSurface`, which may be
- * created by calling IComponentStore::createInputSurface(). Once created, the
- * client may
- *   1. write data to it via the `IGraphicBufferProducer` interface; and
- *   2. use it as input to a Codec2 encoder.
- *
- * @sa IInputSurfaceConnection, IComponentStore::createInputSurface(),
- *     IComponent::connectToInputSurface().
+ * Input surface that can be configured for the IComponent.
  */
-interface IInputSurface {
-    /**
-     * Returns the producer interface into the internal buffer queue.
-     *
-     * @return producer `IGraphicBufferProducer` instance. This must not be
-     * null.
-     */
-    getGraphicBufferProducer() generates (IGraphicBufferProducer producer);
+interface IInputSurface extends IGraphicBufferProducer {
 
     /**
-     * Returns the @ref IConfigurable instance associated to this input surface.
+     * Connects this input surface to a component.
      *
-     * @return configurable `IConfigurable` instance. This must not be null.
+     * This call must return within 100 ms.
+     *
+     * @param component The component to connect to. This must have type
+     *     IComponent.
+     * @return status Status of the call, which may be
+     *   - OK        - The operation succeeded.
+     *   - BAD_STATE - The component is in running state.
+     *   - DUPLICATE - The surface is already connected to a component.
+     *   - NO_MEMORY - Could not allocate memory to connect to the component.
+     *   - CORRUPTED - Some unknown error prevented the connection. (unexpected)
+     * @return connection Connection object that is used to disconnect
+     *     from the component.
+     */
+    connectToComponent(
+            IComponent component
+        ) generates (
+            Status status,
+            IInputSurfaceConnection connection
+        );
+
+    /**
+     * Returns the Codec 2.0 configuration object for this surface.
+     *
+     * @return configurable The configuration object for this surface.
      */
     getConfigurable() generates (IConfigurable configurable);
+
 };
 
diff --git a/media/c2/1.0/IInputSurfaceConnection.hal b/media/c2/1.0/IInputSurfaceConnection.hal
index efd9c6e..500091d 100644
--- a/media/c2/1.0/IInputSurfaceConnection.hal
+++ b/media/c2/1.0/IInputSurfaceConnection.hal
@@ -16,22 +16,20 @@
 
 package android.hardware.media.c2@1.0;
 
-import IConfigurable;
-
-/**
- * Connection between a component and an input surface.
- *
- * An instance of `IInputSurfaceConnection` contains an `IConfigurable`
- * interface for querying and configuring properties of the connection.
- */
 interface IInputSurfaceConnection {
+
     /**
-     * Returns the @ref IConfigurable instance associated to this connection.
+     * Disconnects this input surface from the component.
      *
-     * This can be used to customize the connection.
+     * This call must return within 100 ms.
      *
-     * @return configurable `IConfigurable` instance. This must not be null.
+     * @return status Status of the call, which may be
+     *   - OK        - The operation succeeded.
+     *   - BAD_STATE - The component is not in running state.
+     *   - NOT_FOUND - The surface is not connected to a component.
+     *   - CORRUPTED - Some unknown error prevented the connection. (unexpected)
      */
-    getConfigurable() generates (IConfigurable configurable);
+    disconnect() generates (Status status);
+
 };
 
diff --git a/media/c2/1.0/types.hal b/media/c2/1.0/types.hal
index 7b75041..c06b415 100644
--- a/media/c2/1.0/types.hal
+++ b/media/c2/1.0/types.hal
@@ -16,280 +16,222 @@
 
 package android.hardware.media.c2@1.0;
 
-import android.hardware.media.bufferpool@2.0::BufferStatusMessage;
+import android.hardware.media.bufferpool@1.0::BufferStatusMessage;
 
-/**
- * Common return values for Codec2 operations.
- */
 enum Status : int32_t {
-    /** Operation completed successfully. */
+    /** operation completed successfully */
     OK        = 0,
 
     // bad input
 
-    /** Argument has invalid value (user error). */
+    /** argument has invalid value (user error) */
     BAD_VALUE = -22,
-    /** Argument uses invalid index (user error). */
+    /** argument uses invalid index (user error) */
     BAD_INDEX = -75,
-    /** Argument/Index is valid but not possible. */
+    /** argument/index is valid but not possible */
     CANNOT_DO = -2147483646,
 
     // bad sequencing of events
 
-    /** Object already exists. */
+    /** object already exists */
     DUPLICATE = -17,
-    /** Object not found. */
+    /** object not found */
     NOT_FOUND = -2,
-    /** Operation is not permitted in the current state. */
+    /** operation is not permitted in the current state */
     BAD_STATE = -38,
-    /** Operation would block but blocking is not permitted. */
+    /** operation would block but blocking is not permitted */
     BLOCKING  = -9930,
 
     // bad environment
 
-    /** Not enough memory to complete operation. */
+    /** not enough memory to complete operation */
     NO_MEMORY = -12,
-    /** Missing permission to complete operation. */
+    /** missing permission to complete operation */
     REFUSED   = -1,
 
-    /** Operation did not complete within timeout. */
+    /** operation did not complete within timeout */
     TIMED_OUT = -110,
 
     // missing functionality
 
-    /** Operation is not implemented/supported (optional only). */
+    /** operation is not implemented/supported (optional only) */
     OMITTED   = -74,
 
     // unknown fatal
 
-    /** Some unexpected error prevented the operation. */
+    /** some unexpected error prevented the operation */
     CORRUPTED = -2147483648,
 
     // uninitialized
 
-    /** Status has not been initialized. */
+    /** status has not been initialized */
     NO_INIT   = -19,
 };
 
 /**
- * C2Param structure index.
- *
- * This is a number that is unique for each C2Param structure type.
- *
- * @sa Codec 2.0 standard.
+ * Codec 2.0 parameter index
  */
 typedef uint32_t ParamIndex;
 
 /**
- * Flattened representation of C2Param objects.
+ * Codec 2.0 parameter structure
  *
- * The `Params` type is an array of bytes made up by concatenating a list of
- * C2Param objects. The start index (offset into @ref Params) of each C2Param
- * object in the list is divisible by 8. Up to 7 padding bytes may be added
- * after each C2Param object to achieve this 64-bit alignment.
- *
- * Each C2Param object has the following layout:
- * - 4 bytes: C2Param structure index (of type @ref ParamIndex) identifying the
- *   type of the C2Param object.
- * - 4 bytes: size of the C2Param object (unsigned 4-byte integer).
- * - (size - 8) bytes: data of the C2Param object.
- *
- * In order to interpret each C2Param object correctly, its structure must be
- * described by IComponentStore::getStructDescriptors().
- *
- * @note Please refer to the Codec 2.0 standard for the list of standard
- * parameter structures.
- *
- * @sa Codec 2.0 standard.
+ * The description of a Params is provided by supplying a ParamIndex to
+ * IComponentStore::getStructDescriptors().
  */
 typedef vec<uint8_t> Params;
 
 /**
- * Identifying information of a field relative to a known C2Param structure.
- *
- * Within a given C2Param structure, each field is uniquely identified by @ref
- * FieldId.
+ * Struct uniquely specifying a field in an arbitrary parameter structure.
  */
 struct FieldId {
-    /** Offset of the field in bytes. */
+    /** Offset of the field in bytes */
     uint32_t offset;
-    /** Size of the field in bytes. */
+    /** Size of the field in bytes */
     uint32_t size;
 };
 
 /**
- * Reference to a field in a C2Param structure.
+ * Struct representing a location of a field in a parameter with a given index.
  */
 struct ParamField {
-    /** Index of the C2Param structure. */
+    /** Index of the parameter */
     ParamIndex index;
-    /** Identifier of the field inside the C2Param structure. */
+    /** Field identifier */
     FieldId fieldId;
 };
 
 /**
- * Usage description of a C2Param structure.
- *
- * @ref ParamDescriptor is returned by IConfigurable::querySupportedParams().
+ * Struct describing basic properties of a parameter with a given index.
  */
 struct ParamDescriptor {
-    /**
-     * Index of the C2Param structure being described.
-     */
+    /** Parameter index */
     ParamIndex index;
 
     enum Attrib : uint32_t {
         /**
-         * The parameter is required to be specified.
+         * Parameter is required to be specified.
          */
         REQUIRED   = 1u << 0,
         /**
-         * The parameter retains its value.
+         * Parameter retains its value.
          */
         PERSISTENT = 1u << 1,
         /**
-         * The parameter is strict.
+         * Parameter is strict.
          */
         STRICT     = 1u << 2,
         /**
-         * The parameter is publicly read-only.
+         * Parameter is publicly read-only.
          */
         READ_ONLY  = 1u << 3,
         /**
-         * The parameter must not be visible to clients.
+         * Parameter must not be visible to clients.
          */
         HIDDEN     = 1u << 4,
         /**
-         * The parameter must not be used by framework (other than testing).
+         * Parameter must not be used by framework (other than testing).
          */
         INTERNAL   = 1u << 5,
         /**
-         * The parameter is publicly constant (hence read-only).
+         * Parameter is publicly constant (hence read-only).
          */
         CONST      = 1u << 6,
     };
+    /** Parameter attributes */
     bitfield<Attrib> attrib;
 
-    /**
-     * Name of the structure. This must be unique for each structure.
-     */
+    /** Parameter name */
     string name;
 
-    /**
-     * Indices of other C2Param structures that this C2Param structure depends
-     * on.
-     */
+    /** index of other parameters that this parameter depends on */
     vec<ParamIndex> dependencies;
 };
 
-// Generic way to describe supported numeric values for Codec2 interfaces.
+// Generic way to describe supported numeric values for Codec 2.0 interfaces.
 
 /**
- * An untyped value that can fit in 64 bits, the type of which is communicated
- * via a separate channel (@ref FieldSupportedValues.type).
+ * An untyped value that can fit on 64 bits - the type of which is communicated
+ * via a separate channel (FieldType).
  */
 typedef uint64_t PrimitiveValue;
 
 /*
- * Description of supported values for a field.
+ * Generic supported values for a field.
  *
- * This can be a continuous range or a discrete set of values.
+ * This can be either a range or a set of values. The range can be linear or
+ * geometric with clear minimum and maximum values, and can have an optional
+ * step size or geometric ratio. Values can optionally represent flags.
  */
 struct FieldSupportedValues {
-    /**
-     * Used if #type is `RANGE`.
-     *
-     * If the `step` member is 0, and `num` and `denom` are both 1, the `Range`
-     * structure represents a closed interval bounded by `min` and `max`.
-     *
-     * Otherwise, the #Range structure represents a finite sequence of numbers
-     * produced from the following recurrence relation:
-     *
-     * @code
-     * v[0] = min
-     * v[i] = v[i - 1] * num / denom + step ; i >= 1
-     * @endcode
-     *
-     * Both the ratio `num / denom` and the value `step` must be positive. The
-     * last number in the sequence described by this #Range structure is the
-     * largest number in the sequence that is smaller than or equal to `max`.
-     *
-     * @note
-     * The division in the formula may truncate the result if the data type of
-     * these values is an integral type.
-     */
     struct Range {
-        /**
-         * Lower end of the range (inclusive).
-         */
         PrimitiveValue min;
-        /**
-         * Upper end of the range (inclusive).
-         */
         PrimitiveValue max;
-        /**
-         * The non-homogeneous term in the recurrence relation.
-         */
         PrimitiveValue step;
-        /**
-         * The numerator of the scale coefficient in the recurrence relation.
-         */
         PrimitiveValue num;
-        /**
-         * The denominator of the scale coefficient in the recurrence relation.
-         */
         PrimitiveValue denom;
     };
 
     enum Type : int32_t {
         /** No supported values */
-        EMPTY = 0,
-        /** Numeric range, described in a #Range structure */
+        EMPTY,
+        /** Numeric range that can be continuous or discrete */
         RANGE,
         /** List of values */
         VALUES,
         /** List of flags that can be OR-ed */
         FLAGS,
+        /** Other representations */
+        OTHER = 0xffffffff,
     };
     /**
-     * Type of the supported values.
+     * Type of the supported values. The framework may not recognize `OTHER`.
      */
     Type type;
+    /**
+     * Codec2.0 type code of the supported values.
+     *   * If #type is `OTHER`, #typeOther can be used to give more information.
+     *     In this case, the interpretation of this structure is
+     *     implementation-defined.
+     *   * For all other values of #type, #typeOther is not used.
+     * The framework may not inspect this value.
+     */
+    int32_t typeOther;
+
+    /*
+     * If #type = EMPTY, #range and #value are unused.
+     */
 
     /**
-     * When #type is #Type.RANGE, #range shall specify the range of possible
-     * values.
+     * If #type = RANGE, #range will specify the range of possible values.
      *
-     * The intended type of members of #range shall be clear in the context
-     * where `FieldSupportedValues` is used.
+     * The intended type of members of #range will be clear in the context where
+     * FieldSupportedValues is used.
      */
     Range range;
 
     /**
-     * When #type is #Type.VALUES or #Type.FLAGS, #value shall list supported
-     * values/flags.
+     * If #type is `VALUES` or `FLAGS`, #value will list supported values.
      *
-     * The intended type of components of #value shall be clear in the context
-     * where `FieldSupportedValues` is used.
+     * The intended type of components of #value will be clear in the context
+     * where FieldSupportedValues is used.
      */
     vec<PrimitiveValue> values;
 };
 
 /**
- * Supported values for a field.
+ * Supported values for a specific field.
  *
  * This is a pair of the field specifier together with an optional supported
  * values object. This structure is used when reporting parameter configuration
  * failures and conflicts.
  */
 struct ParamFieldValues {
-    /**
-     * Reference to a field or a C2Param structure.
-     */
+    /** the field or parameter */
     ParamField paramOrField;
 
     /**
-     * Optional supported values for the field if #paramOrField specifies an
+     * optional supported values for the field if paramOrField specifies an
      * actual field that is numeric (non struct, blob or string). Supported
      * values for arrays (including string and blobs) describe the supported
      * values for each element (character for string, and bytes for blobs). It
@@ -299,18 +241,18 @@
 };
 
 /**
- * Description of a field inside a C2Param structure.
+ * Field descriptor.
  */
 struct FieldDescriptor {
 
-    /** Location of the field in the C2Param structure */
+    /** Field id */
     FieldId fieldId;
 
     /**
-     * Possible types of the field.
+     * Possible types of a field.
      */
     enum Type : uint32_t {
-        NO_INIT = 0,
+        NO_INIT,
         INT32,
         UINT32,
         CNTR32,
@@ -319,227 +261,186 @@
         CNTR64,
         FLOAT,
         /**
-         * Fixed-size string (POD).
+         * Fixed-size string (POD)
          */
         STRING = 0x100,
         /**
-         * A blob has no sub-elements and can be thought of as an array of
-         * bytes. However, bytes cannot be individually addressed by clients.
+         * blobs have no sub-elements and can be thought of as byte arrays.
+         * However, bytes cannot be individually addressed by clients.
          */
         BLOB,
         /**
-         * The field is a structure that may contain other fields.
+         * Structs. Marked with this flag in addition to their coreIndex.
          */
-        STRUCT = 0x20000,
+        STRUCT_FLAG = 0x20000,
     };
     /**
      * Type of the field.
      */
     bitfield<Type> type;
 
-    /**
-     * If #type is #Type.STRUCT, #structIndex is the C2Param structure index;
-     * otherwise, #structIndex is not used.
+    /** Extent of the field */
+    uint32_t length;
+    /*
+     * Note: the last member of a param struct can be of arbitrary length (e.g.
+     * if it is T[] array, which extends to the last byte of the parameter.)
+     * This is marked with extent 0.
      */
-    ParamIndex structIndex;
 
-    /**
-     * Extent of the field.
-     * - For a non-array field, #extent is 1.
-     * - For a fixed-length array field, #extent is the length. An array field
-     *   of length 1 is indistinguishable from a non-array field.
-     * - For a variable-length array field, #extent is 0. This can only occur as
-     *   the last member of a C2Param structure.
-     */
-    uint32_t extent;
-
-    /**
-     * Name of the field. This must be unique for each field in the same
-     * structure.
-     */
+    /** Name of the field */
     string name;
-
-    /**
-     * Named value type. This is used for defining an enum value for a numeric
-     * type.
-     */
+    /** Named value type */
     struct NamedValue {
-        /**
-         * Name of the enum value. This must be unique for each enum value in
-         * the same field.
-         */
         string name;
-        /**
-         * Underlying value of the enum value. Multiple enum names may have the
-         * same underlying value.
-         */
         PrimitiveValue value;
     };
-    /**
-     * List of enum values. This is not used when #type is not one of the
-     * numeric types.
-     */
+    /** Named values for the field */
     vec<NamedValue> namedValues;
 };
 
 /**
- * Description of a C2Param structure. It consists of an index and a list of
- * `FieldDescriptor`s.
+ * Struct descriptor.
  */
 struct StructDescriptor {
-    /**
-     * Index of the structure.
-     */
+    /** Struct type */
     ParamIndex type;
-    /**
-     * List of fields in the structure.
-     *
-     * Fields are ordered by their offsets. A field that is a structure is
-     * ordered before its members.
-     */
+    /** Field descriptors for each field */
     vec<FieldDescriptor> fields;
 };
 
 /**
- * Information describing the reason the parameter settings may fail, or may be
- * overridden.
+ * Information describing the reason a parameter settings may fail, or
+ * may be overriden.
  */
 struct SettingResult {
-    /** Failure code */
+    /** Failure code (of Codec 2.0 SettingResult failure type) */
     enum Failure : uint32_t {
+        /** Parameter is read-only and cannot be set. */
+        READ_ONLY,
+        /** Parameter mismatches input data. */
+        MISMATCH,
+        /** Parameter does not accept value. */
+        BAD_VALUE,
         /** Parameter is not supported. */
         BAD_TYPE,
         /** Parameter is not supported on the specific port. */
         BAD_PORT,
         /** Parameter is not supported on the specific stream. */
         BAD_INDEX,
-        /** Parameter is read-only and cannot be set. */
-        READ_ONLY,
-        /** Parameter mismatches input data. */
-        MISMATCH,
-        /** Strict parameter does not accept value for the field at all. */
-        BAD_VALUE,
-        /**
-         * Strict parameter field value is in conflict with an/other
-         * setting(s).
-         */
+        /** Parameter is in conflict with an/other setting(s). */
         CONFLICT,
         /**
-         * Parameter field is out of range due to other settings. (This failure
-         * mode can only be used for strict calculated parameters.)
+         * Parameter is out of range due to other settings. (This failure mode
+         * can only be used for strict parameters.)
          */
         UNSUPPORTED,
         /**
-         * Field does not access the requested parameter value at all. It has
-         * been corrected to the closest supported value. This failure mode is
-         * provided to give guidance as to what are the currently supported
-         * values for this field (which may be a subset of the at-all-potential
-         * values).
-         */
-        INFO_BAD_VALUE,
-        /**
          * Requested parameter value is in conflict with an/other setting(s)
          * and has been corrected to the closest supported value. This failure
-         * mode is given to provide guidance as to what are the currently
-         * supported values as well as to optionally provide suggestion to the
-         * client as to how to enable the requested parameter value.
-         */
+         * mode is given to provide suggestion to the client as to how to enable
+         * the requested parameter value. */
         INFO_CONFLICT,
+        /**
+         * This failure mode is reported when all the above failure modes do not
+         * apply.
+         */
+        OTHER = 0xffffffff,
     };
+    /**
+     * The failure type. The framework might not recognize `OTHER`.
+     */
     Failure failure;
+    /**
+     * The failure code.
+     *   * If #failure is `OTHER`, #failureOther can be used to give more
+     *     information.
+     *   * For all other values of #failure, #failureOther is not used.
+     * The framework may not inspect this value.
+     */
+    uint32_t failureOther;
 
     /**
-     * Failing (or corrected) field or parameter and optionally, currently
-     * supported values for the field. Values must only be set for field
-     * failures other than `BAD_VALUE`, and only if they are different from the
-     * globally supported values (e.g. due to restrictions by another parameter
-     * or input data).
+     * Failing (or corrected) field. Currently supported values for the field.
+     * This is set if different from the globally supported values (e.g. due to
+     * restrictions by another param or input data)
      */
     ParamFieldValues field;
 
     /**
-     * Conflicting parameters or fields with (optional) suggested values for any
-     * conflicting fields to avoid the conflict. Values must only be set for
-     * `CONFLICT`, `UNSUPPORTED` or `INFO_CONFLICT` failure code.
+     * Conflicting parameters or fields with
+     * (optional) suggested values for any conflicting fields to avoid the conflict.
      */
     vec<ParamFieldValues> conflicts;
 };
 
 /**
- * Ordering information of @ref FrameData objects. Each member is used for
- * comparing urgency: a smaller difference from a reference value indicates that
- * the associated Work object is more urgent. The reference value for each
- * member is initialized the first time it is communicated between the client
- * and the codec, and it may be updated to later values that are communicated.
- *
- * Each member of `WorkOrdinal` is stored as an unsigned integer, but the actual
- * order it represents is derived by subtracting the reference value, then
- * interpreting the result as a signed number with the same storage size (using
- * two's complement).
- *
- * @note `WorkOrdinal` is the HIDL counterpart of `C2WorkOrdinalStruct` in the
- * Codec 2.0 standard.
+ * Data structure for ordering Work objects. Each member is used for comparing
+ * urgency in the same fashion: a smaller value indicates that the associated
+ * Work object is more urgent.
  */
 struct WorkOrdinal {
     /**
-     * Timestamp in microseconds.
+     * Timestamp in microseconds - can wrap around.
      */
     uint64_t timestampUs;
     /**
-     * Frame index.
+     * Frame index - can wrap around.
      */
     uint64_t frameIndex;
     /**
-     * Component specific frame ordinal.
+     * Component specific frame ordinal - can wrap around.
      */
     uint64_t customOrdinal;
 };
 
 /**
- * Storage type for `BaseBlock`.
- *
- * A `BaseBlock` is a representation of a codec memory block. Coded data,
- * decoded data, codec-specific data, and other codec-related data are all sent
- * in the form of BaseBlocks.
+ * A structure that holds information of a Block. There are two types of Blocks:
+ * NATIVE and POOLED. Each type has its own way of identifying blocks.
  */
-safe_union BaseBlock {
+struct BaseBlock {
+    enum Type : int32_t {
+        NATIVE,
+        POOLED,
+    };
     /**
-     * #nativeBlock is the opaque representation of a buffer.
+     * There are two types of blocks: NATIVE and POOLED.
+     */
+    Type type;
+
+    /**
+     * A "NATIVE" block is represented by a native handle.
      */
     handle nativeBlock;
-    /**
-     * #pooledBlock is a reference to a buffer handled by a BufferPool.
+
+    /*
+     * A "POOLED" block is represented by `BufferStatusMessage`.
      */
     BufferStatusMessage pooledBlock;
 };
 
 /**
- * Reference to a @ref BaseBlock within a @ref WorkBundle.
- *
- * `Block` contains additional attributes that `BaseBlock` does not. These
- * attributes may differ among `Block` objects that refer to the same
- * `BaseBlock` in the same `WorkBundle`.
+ * A Block in transfer consists of an index into an array of BaseBlock plus some
+ * extra information. One BaseBlock may occur in multiple blocks in one
+ * `WorkBundle`.
  */
 struct Block {
     /**
-     * Identity of a `BaseBlock` within a `WorkBundle`. This is an index into
-     * #WorkBundle.baseBlocks.
+     * Identity of the BaseBlock within a WorkBundle. This is an index into the
+     * `baseBlocks` array of a `WorkBundle` object.
      */
     uint32_t index;
     /**
-     * Metadata associated with this `Block`.
+     * Metadata associated with the block.
      */
     Params meta;
     /**
-     * Fence for synchronizing `Block` access.
+     * Fence for synchronizing block access.
      */
     handle fence;
 };
 
 /**
- * A codec buffer, which is a collection of @ref Block objects and metadata.
- *
- * This is a part of @ref FrameData.
+ * Type of buffers processed by a component.
  */
 struct Buffer {
     /**
@@ -553,37 +454,23 @@
 };
 
 /**
- * An extension of @ref Buffer that also contains a C2Param structure index.
- *
- * This is a part of @ref FrameData.
+ * An extension of Buffer that also contains an index.
  */
 struct InfoBuffer {
-    /**
-     * A C2Param structure index.
-     */
     ParamIndex index;
-    /**
-     * Associated @ref Buffer object.
-     */
     Buffer buffer;
 };
 
 /**
- * Data for an input frame or an output frame.
- *
- * This structure represents a @e frame with its metadata. A @e frame consists
- * of an ordered set of buffers, configuration changes, and info buffers along
- * with some non-configuration metadata.
- *
- * @note `FrameData` is the HIDL counterpart of `C2FrameData` in the Codec 2.0
- * standard.
+ * This structure represents a frame with its metadata. A frame consists of an
+ * ordered set of buffers, configuration changes, and info buffers along with
+ * some non-configuration metadata.
  */
 struct FrameData {
     enum Flags : uint32_t {
         /**
-         * For input frames: no output frame shall be generated when processing
+         * For input frames: no output frame will be generated when processing
          * this frame, but metadata must still be processed.
-         *
          * For output frames: this frame must be discarded but metadata is still
          * valid.
          */
@@ -595,183 +482,92 @@
         END_OF_STREAM = (1 << 1),
         /**
          * This frame must be discarded with its metadata.
-         *
-         * This flag is only set by components, e.g. as a response to the flush
+         * This flag is only set by components - e.g. as a response to the flush
          * command.
          */
         DISCARD_FRAME = (1 << 2),
         /**
-         * This frame is not the last frame produced for the input.
-         *
-         * This flag is normally set by the component - e.g. when an input frame
-         * results in multiple output frames, this flag is set on all but the
-         * last output frame.
-         *
-         * Also, when components are chained, this flag should be propagated
-         * down the work chain. That is, if set on an earlier frame of a
-         * work-chain, it should be propagated to all later frames in that
-         * chain. Additionally, components down the chain could set this flag
-         * even if not set earlier, e.g. if multiple output frames are generated
-         * at that component for the input frame.
-         */
-        FLAG_INCOMPLETE = (1 << 3),
-        /**
          * This frame contains only codec-specific configuration data, and no
          * actual access unit.
          *
-         * @deprecated Pass codec configuration with the codec-specific
+         * \deprecated Pass codec configuration with the codec-specific
          * configuration info together with the access unit.
          */
         CODEC_CONFIG  = (1u << 31),
     };
 
     /**
-     * Frame flags, as described in #Flags.
+     * Frame flags.
      */
     bitfield<Flags> flags;
 
     /**
-     * @ref WorkOrdinal of the frame.
+     * Ordinal of the frame.
      */
     WorkOrdinal ordinal;
 
     /**
-     * List of frame buffers.
+     * Frame buffers.
      */
     vec<Buffer> buffers;
 
     /**
-     * List of configuration updates.
+     * Params determining a configuration update.
      */
     Params configUpdate;
 
     /**
-     * List of info buffers.
+     * Info buffers.
      */
     vec<InfoBuffer> infoBuffers;
 };
 
 /**
- * In/out structure containing some instructions for and results from output
- * processing.
- *
- * This is a part of @ref Work. One `Worklet` corresponds to one output
- * @ref FrameData. The client must construct an original `Worklet` object inside
- * a @ref Work object for each expected output before calling
- * IComponent::queue().
+ * Struct for
  */
 struct Worklet {
     /**
-     * Component id. (Input)
-     *
-     * This is used only when tunneling is enabled.
-     *
-     * When used, this must match the return value from IConfigurable::getId().
+     * List of Params describing tunings.
      */
-    uint32_t componentId;
+    vec<Params> tunings;
 
     /**
-     * List of C2Param objects describing tunings to be applied before
-     * processing this `Worklet`. (Input)
-     */
-    Params tunings;
-
-    /**
-     * Flag determining whether this `Worklet` has output or not.
-     */
-    bool hasOutput;
-
-    /**
-     * List of failures. (Output)
+     * List of failures.
      */
     vec<SettingResult> failures;
 
     /**
-     * Output frame data. (Output)
+     * Output frame data.
      */
     FrameData output;
+
+    /* Note: Component id is not necessary as tunneling is not supported. */
 };
 
 /**
- * A collection of input data to and output data from the component.
- *
- * A `Work` object holds information about a single work item. It is created by
- * the client and passed to the component via IComponent::queue(). The component
- * has two ways of returning a `Work` object to the client:
- *   1. If the queued `Work` object has been successfully processed,
- *      IComponentListener::onWorkDone() shall be called to notify the listener,
- *      and the output shall be included in the returned `Work` object.
- *   2. If the client calls IComponent::flush(), a `Work` object that has not
- *      been processed shall be returned.
- *
- * `Work` is a part of @ref WorkBundle.
+ * This structure holds information about a single work item. It must be passed
+ * by the client to the component.
  */
 struct Work {
     /**
-     * Additional work chain info not part of this work.
-     */
-    Params chainInfo;
-
-    /**
-     * @ref FrameData for the input.
+     * FrameData for the input. Indices of Blocks inside #input refer to
+     * BaseBlocks in the member `blocks` of the containing `WorkBundle`.
      */
     FrameData input;
-
     /**
-     * The chain of `Worklet`s.
-     *
-     * The length of #worklets is 1 when tunneling is not enabled.
-     *
-     * If #worklets has more than a single element, the tunnels between
-     * successive components of the work chain must have been successfully
-     * pre-registered at the time that the `Work` is submitted. Allocating the
-     * output buffers in the `Worklet`s is the responsibility of each component
-     * in the chain.
-     *
-     * Upon `Work` submission, #worklets must be an appropriately sized vector
-     * containing `Worklet`s with @ref Worklet.hasOutput set to `false`. After a
-     * successful processing, all but the final `Worklet` in the returned
-     * #worklets must have @ref Worklet.hasOutput set to `false`.
+     * Worklet. Indices of Blocks inside `worklet.output` refer to
+     * BaseBlocks in the member `blocks` of the containing `WorkBundle`.
      */
-    vec<Worklet> worklets;
-
+    Worklet worklet;
     /**
-     * The number of `Worklet`s successfully processed in this chain.
-     *
-     * This must be initialized to 0 by the client when the `Work` is submitted,
-     * and it must contain the number of `Worklet`s that were successfully
-     * processed when the `Work` is returned to the client.
-     *
-     * #workletsProcessed cannot exceed the length of #worklets. If
-     * #workletsProcessed is smaller than the length of #worklets, #result
-     * cannot be `OK`.
+     * Whether the worklet was processed or not.
      */
-    uint32_t workletsProcessed;
-
-    /**
-     * The final outcome of the `Work` (corresponding to #workletsProcessed).
-     *
-     * The value of @ref Status.OK implies that all `Worklet`s have been
-     * successfully processed.
-     */
+    bool workletProcessed;
     Status result;
 };
 
 /**
- * List of `Work` objects.
- *
- * `WorkBundle` is used in IComponent::queue(), IComponent::flush() and
- * IComponentListener::onWorkDone(). A `WorkBundle` object consists of a list of
- * `Work` objects and a list of `BaseBlock` objects. Bundling multiple `Work`
- * objects together provides two benefits:
- *   1. Batching of `Work` objects can reduce the number of IPC calls.
- *   2. If multiple `Work` objects contain `Block`s that refer to the same
- *      `BaseBlock`, the number of `BaseBlock`s that is sent between processes
- *      is also reduced.
- *
- * @note `WorkBundle` is the HIDL counterpart of the vector of `C2Work` in the
- * Codec 2.0 standard. The presence of #baseBlocks helps with minimizing the
- * data transferred over an IPC.
+ * This structure holds a list of Work objects and a list of BaseBlocks.
  */
 struct WorkBundle {
     /**
@@ -785,48 +581,27 @@
 };
 
 /**
- * Query information for supported values of a field. This is used as input to
- * IConfigurable::querySupportedValues().
+ * This structure describes a query for supported values of a field. This is
+ * used as input to IConfigurable::queryFieldSupportedValues().
  */
 struct FieldSupportedValuesQuery {
-    /**
-     * Identity of the field to query.
-     */
-    ParamField field;
-
     enum Type : uint32_t {
-        /** Query all possible values regardless of other settings. */
+        /** Query all possible values regardless of other settings */
         POSSIBLE,
-        /** Query currently possible values given dependent settings. */
+        /** Query currently possible values given dependent settings */
         CURRENT,
     };
-    /**
-     * Type of the query. See #Type for more information.
-     */
+
+    ParamField field;
     Type type;
 };
 
 /**
  * This structure is used to hold the result from
- * IConfigurable::querySupportedValues().
+ * IConfigurable::queryFieldSupportedValues().
  */
 struct FieldSupportedValuesQueryResult {
-    /**
-     * Result of the query. Possible values are
-     * - `OK`: The query was successful.
-     * - `BAD_STATE`: The query was requested when the `IConfigurable` instance
-     *   was in a bad state.
-     * - `BAD_INDEX`: The requested field was not recognized.
-     * - `TIMED_OUT`: The query could not be completed in a timely manner.
-     * - `BLOCKING`: The query must block, but the parameter `mayBlock` in the
-     *   call to `querySupportedValues()` was `false`.
-     * - `CORRUPTED`: Some unknown error occurred.
-     */
     Status status;
-
-    /**
-     * Supported values. This is meaningful only when #status is `OK`.
-     */
     FieldSupportedValues values;
 };
 
diff --git a/media/omx/1.0/vts/functional/audio/Android.bp b/media/omx/1.0/vts/functional/audio/Android.bp
index f517fa1..7418bb4 100644
--- a/media/omx/1.0/vts/functional/audio/Android.bp
+++ b/media/omx/1.0/vts/functional/audio/Android.bp
@@ -21,6 +21,7 @@
         "VtsHalMediaOmxV1_0TargetAudioEncTest.cpp",
         "media_audio_hidl_test_common.cpp"
     ],
+    test_suites: ["general-tests"],
 }
 
 cc_test {
@@ -30,6 +31,7 @@
         "VtsHalMediaOmxV1_0TargetAudioDecTest.cpp",
         "media_audio_hidl_test_common.cpp"
     ],
+    test_suites: ["general-tests"],
 }
 
 
diff --git a/media/omx/1.0/vts/functional/component/Android.bp b/media/omx/1.0/vts/functional/component/Android.bp
index f76b6e9..970eabe 100644
--- a/media/omx/1.0/vts/functional/component/Android.bp
+++ b/media/omx/1.0/vts/functional/component/Android.bp
@@ -18,5 +18,6 @@
     name: "VtsHalMediaOmxV1_0TargetComponentTest",
     defaults: ["VtsHalMediaOmxV1_0Defaults"],
     srcs: ["VtsHalMediaOmxV1_0TargetComponentTest.cpp"],
+    test_suites: ["general-tests"],
 }
 
diff --git a/media/omx/1.0/vts/functional/master/Android.bp b/media/omx/1.0/vts/functional/master/Android.bp
index 4a45e69..cf3f15d 100644
--- a/media/omx/1.0/vts/functional/master/Android.bp
+++ b/media/omx/1.0/vts/functional/master/Android.bp
@@ -18,5 +18,6 @@
     name: "VtsHalMediaOmxV1_0TargetMasterTest",
     defaults: ["VtsHalMediaOmxV1_0Defaults"],
     srcs: ["VtsHalMediaOmxV1_0TargetMasterTest.cpp"],
+    test_suites: ["general-tests"],
 }
 
diff --git a/media/omx/1.0/vts/functional/video/Android.bp b/media/omx/1.0/vts/functional/video/Android.bp
index f0da2b3..c7e0424 100644
--- a/media/omx/1.0/vts/functional/video/Android.bp
+++ b/media/omx/1.0/vts/functional/video/Android.bp
@@ -21,6 +21,7 @@
         "VtsHalMediaOmxV1_0TargetVideoDecTest.cpp",
         "media_video_hidl_test_common.cpp"
     ],
+    test_suites: ["general-tests"],
 }
 
 cc_test {
@@ -33,4 +34,5 @@
     static_libs: [
         "libnativewindow",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/memtrack/1.0/vts/functional/Android.bp b/memtrack/1.0/vts/functional/Android.bp
index 2d833e7..d682e0b 100644
--- a/memtrack/1.0/vts/functional/Android.bp
+++ b/memtrack/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalMemtrackV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.memtrack@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/neuralnetworks/1.0/vts/functional/Android.bp b/neuralnetworks/1.0/vts/functional/Android.bp
index ffba45c..dd6f934 100644
--- a/neuralnetworks/1.0/vts/functional/Android.bp
+++ b/neuralnetworks/1.0/vts/functional/Android.bp
@@ -39,17 +39,14 @@
     ],
 }
 
-cc_test {
-    name: "VtsHalNeuralnetworksV1_0TargetTest",
+cc_defaults {
+    name: "VtsHalNeuralNetworksTargetTestDefaults",
+    defaults: ["VtsHalTargetTestDefaults"],
     srcs: [
-        "BasicTests.cpp",
-        "GeneratedTests.cpp",
         "ValidateModel.cpp",
         "ValidateRequest.cpp",
-        "ValidationTests.cpp",
         "VtsHalNeuralnetworks.cpp",
     ],
-    defaults: ["VtsHalTargetTestDefaults"],
     static_libs: [
         "android.hardware.neuralnetworks@1.0",
         "android.hardware.neuralnetworks@1.1",
@@ -66,4 +63,23 @@
         "libneuralnetworks_generated_test_harness_headers",
         "libneuralnetworks_generated_tests",
     ],
+    // Bug: http://b/74200014 - Disable arm32 asan since it triggers internal
+    // error in ld.gold.
+    arch: {
+        arm: {
+            sanitize: {
+                never: true,
+            },
+        },
+    },
+}
+
+cc_test {
+    name: "VtsHalNeuralnetworksV1_0TargetTest",
+    defaults: ["VtsHalNeuralNetworksTargetTestDefaults"],
+    srcs: [
+        "BasicTests.cpp",
+        "GeneratedTests.cpp",
+    ],
+    test_suites: ["general-tests"],
 }
diff --git a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
index 1f66c43..d2703cb 100644
--- a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
+++ b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
@@ -36,6 +36,7 @@
 namespace generated_tests {
 using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
 using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
+using ::test_helper::bool8;
 using ::test_helper::compare;
 using ::test_helper::expectMultinomialDistributionWithinTolerance;
 using ::test_helper::filter;
@@ -45,6 +46,7 @@
 using ::test_helper::Int32Operands;
 using ::test_helper::MixedTyped;
 using ::test_helper::MixedTypedExample;
+using ::test_helper::MixedTypedIndex;
 using ::test_helper::Quant8Operands;
 using ::test_helper::resize_accordingly;
 
@@ -63,14 +65,17 @@
     copy_back_<int32_t>(dst, ra, src);
     copy_back_<uint8_t>(dst, ra, src);
     copy_back_<int16_t>(dst, ra, src);
-    static_assert(4 == std::tuple_size<MixedTyped>::value,
+    copy_back_<_Float16>(dst, ra, src);
+    copy_back_<bool8>(dst, ra, src);
+    static_assert(6 == std::tuple_size<MixedTyped>::value,
                   "Number of types in MixedTyped changed, but copy_back function wasn't updated");
 }
 
 // Top level driver for models and examples generated by test_generator.py
 // Test driver for those generated from ml/nn/runtime/test/spec
 void EvaluatePreparedModel(sp<IPreparedModel>& preparedModel, std::function<bool(int)> is_ignored,
-                           const std::vector<MixedTypedExample>& examples, float fpAtol = 1e-5f,
+                           const std::vector<MixedTypedExample>& examples,
+                           bool hasRelaxedFloat32Model = false, float fpAtol = 1e-5f,
                            float fpRtol = 1e-5f) {
     const uint32_t INPUT = 0;
     const uint32_t OUTPUT = 1;
@@ -78,13 +83,20 @@
     int example_no = 1;
     for (auto& example : examples) {
         SCOPED_TRACE(example_no++);
-
         const MixedTyped& inputs = example.operands.first;
         const MixedTyped& golden = example.operands.second;
 
+        const bool hasFloat16Inputs = !std::get<MixedTypedIndex<_Float16>::index>(inputs).empty();
+        if (hasRelaxedFloat32Model || hasFloat16Inputs) {
+            // TODO: Adjust the error limit based on testing.
+            // If in relaxed mode, set the absolute tolerance to be 5ULP of FP16.
+            fpAtol = 5.0f * 0.0009765625f;
+            // Set the relative tolerance to be 5ULP of the corresponding FP precision.
+            fpRtol = 5.0f * 0.0009765625f;
+        }
+
         std::vector<RequestArgument> inputs_info, outputs_info;
         uint32_t inputSize = 0, outputSize = 0;
-
         // This function only partially specifies the metadata (vector of RequestArguments).
         // The contents are copied over below.
         for_all(inputs, [&inputs_info, &inputSize](int index, auto, auto s) {
@@ -228,7 +240,8 @@
     ASSERT_NE(nullptr, preparedModel.get());
 
     float fpAtol = 1e-5f, fpRtol = 5.0f * 1.1920928955078125e-7f;
-    EvaluatePreparedModel(preparedModel, is_ignored, examples, fpAtol, fpRtol);
+    EvaluatePreparedModel(preparedModel, is_ignored, examples,
+                          /*hasRelaxedFloat32Model=*/false, fpAtol, fpRtol);
 }
 
 void Execute(const sp<V1_1::IDevice>& device, std::function<V1_1::Model(void)> create_model,
@@ -272,13 +285,8 @@
     EXPECT_EQ(ErrorStatus::NONE, prepareReturnStatus);
     ASSERT_NE(nullptr, preparedModel.get());
 
-    // TODO: Adjust the error limit based on testing.
-    // If in relaxed mode, set the absolute tolerance to be 5ULP of FP16.
-    float fpAtol = !model.relaxComputationFloat32toFloat16 ? 1e-5f : 5.0f * 0.0009765625f;
-    // Set the relative tolerance to be 5ULP of the corresponding FP precision.
-    float fpRtol = !model.relaxComputationFloat32toFloat16 ? 5.0f * 1.1920928955078125e-7f
-                                                           : 5.0f * 0.0009765625f;
-    EvaluatePreparedModel(preparedModel, is_ignored, examples, fpAtol, fpRtol);
+    EvaluatePreparedModel(preparedModel, is_ignored, examples,
+                          model.relaxComputationFloat32toFloat16);
 }
 
 // TODO: Reduce code duplication.
@@ -323,13 +331,8 @@
     EXPECT_EQ(ErrorStatus::NONE, prepareReturnStatus);
     ASSERT_NE(nullptr, preparedModel.get());
 
-    // TODO: Adjust the error limit based on testing.
-    // If in relaxed mode, set the absolute tolerance to be 5ULP of FP16.
-    float fpAtol = !model.relaxComputationFloat32toFloat16 ? 1e-5f : 5.0f * 0.0009765625f;
-    // Set the relative tolerance to be 5ULP of the corresponding FP precision.
-    float fpRtol = !model.relaxComputationFloat32toFloat16 ? 5.0f * 1.1920928955078125e-7f
-                                                           : 5.0f * 0.0009765625f;
-    EvaluatePreparedModel(preparedModel, is_ignored, examples, fpAtol, fpRtol);
+    EvaluatePreparedModel(preparedModel, is_ignored, examples,
+                          model.relaxComputationFloat32toFloat16);
 }
 
 }  // namespace generated_tests
diff --git a/neuralnetworks/1.0/vts/functional/GeneratedTests.cpp b/neuralnetworks/1.0/vts/functional/GeneratedTests.cpp
index ac1ae60..26b4d8b 100644
--- a/neuralnetworks/1.0/vts/functional/GeneratedTests.cpp
+++ b/neuralnetworks/1.0/vts/functional/GeneratedTests.cpp
@@ -45,6 +45,8 @@
 using ::android::nn::allocateSharedMemory;
 using ::test_helper::MixedTypedExample;
 
+std::vector<Request> createRequests(const std::vector<MixedTypedExample>& examples);
+
 // in frameworks/ml/nn/runtime/tests/generated/
 #include "all_generated_V1_0_vts_tests.cpp"
 
diff --git a/neuralnetworks/1.0/vts/functional/Models.h b/neuralnetworks/1.0/vts/functional/Models.h
deleted file mode 100644
index 268e671..0000000
--- a/neuralnetworks/1.0/vts/functional/Models.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (C) 2018 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 VTS_HAL_NEURALNETWORKS_V1_0_VTS_FUNCTIONAL_MODELS_H
-#define VTS_HAL_NEURALNETWORKS_V1_0_VTS_FUNCTIONAL_MODELS_H
-
-#define LOG_TAG "neuralnetworks_hidl_hal_test"
-
-#include "TestHarness.h"
-
-#include <android/hardware/neuralnetworks/1.0/types.h>
-
-namespace android {
-namespace hardware {
-namespace neuralnetworks {
-namespace V1_0 {
-namespace vts {
-namespace functional {
-
-using MixedTypedExample = test_helper::MixedTypedExample;
-
-#define FOR_EACH_TEST_MODEL(FN)                          \
-    FN(add_broadcast_quant8)                             \
-    FN(add)                                              \
-    FN(add_quant8)                                       \
-    FN(avg_pool_float_1)                                 \
-    FN(avg_pool_float_2)                                 \
-    FN(avg_pool_float_3)                                 \
-    FN(avg_pool_float_4)                                 \
-    FN(avg_pool_float_5)                                 \
-    FN(avg_pool_quant8_1)                                \
-    FN(avg_pool_quant8_2)                                \
-    FN(avg_pool_quant8_3)                                \
-    FN(avg_pool_quant8_4)                                \
-    FN(avg_pool_quant8_5)                                \
-    FN(concat_float_1)                                   \
-    FN(concat_float_2)                                   \
-    FN(concat_float_3)                                   \
-    FN(concat_quant8_1)                                  \
-    FN(concat_quant8_2)                                  \
-    FN(concat_quant8_3)                                  \
-    FN(conv_1_h3_w2_SAME)                                \
-    FN(conv_1_h3_w2_VALID)                               \
-    FN(conv_3_h3_w2_SAME)                                \
-    FN(conv_3_h3_w2_VALID)                               \
-    FN(conv_float_2)                                     \
-    FN(conv_float_channels)                              \
-    FN(conv_float_channels_weights_as_inputs)            \
-    FN(conv_float_large)                                 \
-    FN(conv_float_large_weights_as_inputs)               \
-    FN(conv_float)                                       \
-    FN(conv_float_weights_as_inputs)                     \
-    FN(conv_quant8_2)                                    \
-    FN(conv_quant8_channels)                             \
-    FN(conv_quant8_channels_weights_as_inputs)           \
-    FN(conv_quant8_large)                                \
-    FN(conv_quant8_large_weights_as_inputs)              \
-    FN(conv_quant8)                                      \
-    FN(conv_quant8_overflow)                             \
-    FN(conv_quant8_overflow_weights_as_inputs)           \
-    FN(conv_quant8_weights_as_inputs)                    \
-    FN(depth_to_space_float_1)                           \
-    FN(depth_to_space_float_2)                           \
-    FN(depth_to_space_float_3)                           \
-    FN(depth_to_space_quant8_1)                          \
-    FN(depth_to_space_quant8_2)                          \
-    FN(depthwise_conv2d_float_2)                         \
-    FN(depthwise_conv2d_float_large_2)                   \
-    FN(depthwise_conv2d_float_large_2_weights_as_inputs) \
-    FN(depthwise_conv2d_float_large)                     \
-    FN(depthwise_conv2d_float_large_weights_as_inputs)   \
-    FN(depthwise_conv2d_float)                           \
-    FN(depthwise_conv2d_float_weights_as_inputs)         \
-    FN(depthwise_conv2d_quant8_2)                        \
-    FN(depthwise_conv2d_quant8_large)                    \
-    FN(depthwise_conv2d_quant8_large_weights_as_inputs)  \
-    FN(depthwise_conv2d_quant8)                          \
-    FN(depthwise_conv2d_quant8_weights_as_inputs)        \
-    FN(depthwise_conv)                                   \
-    FN(dequantize)                                       \
-    FN(embedding_lookup)                                 \
-    FN(floor)                                            \
-    FN(fully_connected_float_2)                          \
-    FN(fully_connected_float_large)                      \
-    FN(fully_connected_float_large_weights_as_inputs)    \
-    FN(fully_connected_float)                            \
-    FN(fully_connected_float_weights_as_inputs)          \
-    FN(fully_connected_quant8_2)                         \
-    FN(fully_connected_quant8_large)                     \
-    FN(fully_connected_quant8_large_weights_as_inputs)   \
-    FN(fully_connected_quant8)                           \
-    FN(fully_connected_quant8_weights_as_inputs)         \
-    FN(hashtable_lookup_float)                           \
-    FN(hashtable_lookup_quant8)                          \
-    FN(l2_normalization_2)                               \
-    FN(l2_normalization_large)                           \
-    FN(l2_normalization)                                 \
-    FN(l2_pool_float_2)                                  \
-    FN(l2_pool_float_large)                              \
-    FN(l2_pool_float)                                    \
-    FN(local_response_norm_float_1)                      \
-    FN(local_response_norm_float_2)                      \
-    FN(local_response_norm_float_3)                      \
-    FN(local_response_norm_float_4)                      \
-    FN(logistic_float_1)                                 \
-    FN(logistic_float_2)                                 \
-    FN(logistic_quant8_1)                                \
-    FN(logistic_quant8_2)                                \
-    FN(lsh_projection_2)                                 \
-    FN(lsh_projection)                                   \
-    FN(lsh_projection_weights_as_inputs)                 \
-    FN(lstm2)                                            \
-    FN(lstm2_state2)                                     \
-    FN(lstm2_state)                                      \
-    FN(lstm3)                                            \
-    FN(lstm3_state2)                                     \
-    FN(lstm3_state3)                                     \
-    FN(lstm3_state)                                      \
-    FN(lstm)                                             \
-    FN(lstm_state2)                                      \
-    FN(lstm_state)                                       \
-    FN(max_pool_float_1)                                 \
-    FN(max_pool_float_2)                                 \
-    FN(max_pool_float_3)                                 \
-    FN(max_pool_float_4)                                 \
-    FN(max_pool_quant8_1)                                \
-    FN(max_pool_quant8_2)                                \
-    FN(max_pool_quant8_3)                                \
-    FN(max_pool_quant8_4)                                \
-    FN(mobilenet_224_gender_basic_fixed)                 \
-    FN(mobilenet_quantized)                              \
-    FN(mul_broadcast_quant8)                             \
-    FN(mul)                                              \
-    FN(mul_quant8)                                       \
-    FN(mul_relu)                                         \
-    FN(relu1_float_1)                                    \
-    FN(relu1_float_2)                                    \
-    FN(relu1_quant8_1)                                   \
-    FN(relu1_quant8_2)                                   \
-    FN(relu6_float_1)                                    \
-    FN(relu6_float_2)                                    \
-    FN(relu6_quant8_1)                                   \
-    FN(relu6_quant8_2)                                   \
-    FN(relu_float_1)                                     \
-    FN(relu_float_2)                                     \
-    FN(relu_quant8_1)                                    \
-    FN(relu_quant8_2)                                    \
-    FN(reshape)                                          \
-    FN(reshape_quant8)                                   \
-    FN(reshape_quant8_weights_as_inputs)                 \
-    FN(reshape_weights_as_inputs)                        \
-    FN(resize_bilinear_2)                                \
-    FN(resize_bilinear)                                  \
-    FN(rnn)                                              \
-    FN(rnn_state)                                        \
-    FN(softmax_float_1)                                  \
-    FN(softmax_float_2)                                  \
-    FN(softmax_quant8_1)                                 \
-    FN(softmax_quant8_2)                                 \
-    FN(space_to_depth_float_1)                           \
-    FN(space_to_depth_float_2)                           \
-    FN(space_to_depth_float_3)                           \
-    FN(space_to_depth_quant8_1)                          \
-    FN(space_to_depth_quant8_2)                          \
-    FN(svdf2)                                            \
-    FN(svdf)                                             \
-    FN(svdf_state)                                       \
-    FN(tanh)
-
-#define FORWARD_DECLARE_GENERATED_OBJECTS(function) \
-    namespace function {                            \
-    extern std::vector<MixedTypedExample> examples; \
-    Model createTestModel();                        \
-    }
-
-FOR_EACH_TEST_MODEL(FORWARD_DECLARE_GENERATED_OBJECTS)
-
-#undef FORWARD_DECLARE_GENERATED_OBJECTS
-
-}  // namespace functional
-}  // namespace vts
-}  // namespace V1_0
-}  // namespace neuralnetworks
-}  // namespace hardware
-}  // namespace android
-
-#endif  // VTS_HAL_NEURALNETWORKS_V1_0_VTS_FUNCTIONAL_MODELS_H
diff --git a/neuralnetworks/1.0/vts/functional/ValidationTests.cpp b/neuralnetworks/1.0/vts/functional/ValidationTests.cpp
deleted file mode 100644
index d3cbcff..0000000
--- a/neuralnetworks/1.0/vts/functional/ValidationTests.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2018 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 "neuralnetworks_hidl_hal_test"
-
-#include "Models.h"
-#include "VtsHalNeuralnetworks.h"
-
-namespace android {
-namespace hardware {
-namespace neuralnetworks {
-namespace V1_0 {
-namespace vts {
-namespace functional {
-
-// forward declarations
-std::vector<Request> createRequests(const std::vector<::test_helper::MixedTypedExample>& examples);
-
-// generate validation tests
-#define VTS_CURRENT_TEST_CASE(TestName)                                           \
-    TEST_F(ValidationTest, TestName) {                                            \
-        const Model model = TestName::createTestModel();                          \
-        const std::vector<Request> requests = createRequests(TestName::examples); \
-        validateModel(model);                                                     \
-        validateRequests(model, requests);                                        \
-    }
-
-FOR_EACH_TEST_MODEL(VTS_CURRENT_TEST_CASE)
-
-#undef VTS_CURRENT_TEST_CASE
-
-}  // namespace functional
-}  // namespace vts
-}  // namespace V1_0
-}  // namespace neuralnetworks
-}  // namespace hardware
-}  // namespace android
diff --git a/neuralnetworks/1.1/vts/functional/Android.bp b/neuralnetworks/1.1/vts/functional/Android.bp
index a1c0f1f..3f0c256 100644
--- a/neuralnetworks/1.1/vts/functional/Android.bp
+++ b/neuralnetworks/1.1/vts/functional/Android.bp
@@ -14,40 +14,23 @@
 // limitations under the License.
 //
 
+// Tests for V1_0 models using the V1_1 HAL.
+cc_test {
+    name: "VtsHalNeuralnetworksV1_1CompatV1_0TargetTest",
+    defaults: ["VtsHalNeuralNetworksTargetTestDefaults"],
+    srcs: [
+        "GeneratedTestsV1_0.cpp",
+    ],
+    test_suites: ["general-tests"],
+}
+
+// Tests for V1_1 models.
 cc_test {
     name: "VtsHalNeuralnetworksV1_1TargetTest",
+    defaults: ["VtsHalNeuralNetworksTargetTestDefaults"],
     srcs: [
         "BasicTests.cpp",
         "GeneratedTests.cpp",
-        "ValidateModel.cpp",
-        "ValidateRequest.cpp",
-        "ValidationTests.cpp",
-        "VtsHalNeuralnetworks.cpp",
     ],
-    defaults: ["VtsHalTargetTestDefaults"],
-    static_libs: [
-        "android.hardware.neuralnetworks@1.0",
-        "android.hardware.neuralnetworks@1.1",
-        "android.hardware.neuralnetworks@1.2",
-        "android.hidl.allocator@1.0",
-        "android.hidl.memory@1.0",
-        "libgmock",
-        "libhidlmemory",
-        "libneuralnetworks_utils",
-        "VtsHalNeuralnetworksTest_utils",
-    ],
-    header_libs: [
-        "libneuralnetworks_headers",
-        "libneuralnetworks_generated_test_harness_headers",
-        "libneuralnetworks_generated_tests",
-    ],
-    // Bug: http://b/74200014 - Disable arm32 asan since it triggers internal
-    // error in ld.gold.
-    arch: {
-        arm: {
-            sanitize: {
-                never: true,
-            },
-        },
-    },
+    test_suites: ["general-tests"],
 }
diff --git a/neuralnetworks/1.1/vts/functional/GeneratedTests.cpp b/neuralnetworks/1.1/vts/functional/GeneratedTests.cpp
index 1f49904..290a9d3 100644
--- a/neuralnetworks/1.1/vts/functional/GeneratedTests.cpp
+++ b/neuralnetworks/1.1/vts/functional/GeneratedTests.cpp
@@ -45,8 +45,9 @@
 using ::android::nn::allocateSharedMemory;
 using ::test_helper::MixedTypedExample;
 
+std::vector<Request> createRequests(const std::vector<MixedTypedExample>& examples);
+
 // in frameworks/ml/nn/runtime/tests/generated/
-#include "all_generated_V1_0_vts_tests.cpp"
 #include "all_generated_V1_1_vts_tests.cpp"
 
 }  // namespace functional
diff --git a/neuralnetworks/1.1/vts/functional/GeneratedTestsV1_0.cpp b/neuralnetworks/1.1/vts/functional/GeneratedTestsV1_0.cpp
new file mode 100644
index 0000000..a36b24c
--- /dev/null
+++ b/neuralnetworks/1.1/vts/functional/GeneratedTestsV1_0.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2018 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 "neuralnetworks_hidl_hal_test"
+
+#include "VtsHalNeuralnetworks.h"
+
+#include "Callbacks.h"
+#include "TestHarness.h"
+#include "Utils.h"
+
+#include <android-base/logging.h>
+#include <android/hidl/memory/1.0/IMemory.h>
+#include <hidlmemory/mapping.h>
+
+namespace android {
+namespace hardware {
+namespace neuralnetworks {
+
+namespace generated_tests {
+using ::test_helper::MixedTypedExample;
+extern void Execute(const sp<V1_1::IDevice>&, std::function<V1_1::Model(void)>,
+                    std::function<bool(int)>, const std::vector<MixedTypedExample>&);
+}  // namespace generated_tests
+
+namespace V1_1 {
+namespace vts {
+namespace functional {
+
+using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
+using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
+using ::android::nn::allocateSharedMemory;
+using ::test_helper::MixedTypedExample;
+
+std::vector<Request> createRequests(const std::vector<MixedTypedExample>& examples);
+
+// in frameworks/ml/nn/runtime/tests/generated/
+#include "all_generated_V1_0_vts_tests.cpp"
+
+}  // namespace functional
+}  // namespace vts
+}  // namespace V1_1
+}  // namespace neuralnetworks
+}  // namespace hardware
+}  // namespace android
diff --git a/neuralnetworks/1.1/vts/functional/Models.h b/neuralnetworks/1.1/vts/functional/Models.h
deleted file mode 100644
index 62bc95e..0000000
--- a/neuralnetworks/1.1/vts/functional/Models.h
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright (C) 2018 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 VTS_HAL_NEURALNETWORKS_V1_1_VTS_FUNCTIONAL_MODELS_H
-#define VTS_HAL_NEURALNETWORKS_V1_1_VTS_FUNCTIONAL_MODELS_H
-
-#define LOG_TAG "neuralnetworks_hidl_hal_test"
-
-#include "TestHarness.h"
-
-#include <android/hardware/neuralnetworks/1.0/types.h>
-#include <android/hardware/neuralnetworks/1.1/types.h>
-
-namespace android {
-namespace hardware {
-namespace neuralnetworks {
-namespace V1_1 {
-namespace vts {
-namespace functional {
-
-using MixedTypedExample = test_helper::MixedTypedExample;
-
-#define FOR_EACH_TEST_MODEL(FN)                                  \
-    FN(add)                                                      \
-    FN(add_broadcast_quant8)                                     \
-    FN(add_quant8)                                               \
-    FN(add_relaxed)                                              \
-    FN(avg_pool_float_1)                                         \
-    FN(avg_pool_float_1_relaxed)                                 \
-    FN(avg_pool_float_2)                                         \
-    FN(avg_pool_float_2_relaxed)                                 \
-    FN(avg_pool_float_3)                                         \
-    FN(avg_pool_float_3_relaxed)                                 \
-    FN(avg_pool_float_4)                                         \
-    FN(avg_pool_float_4_relaxed)                                 \
-    FN(avg_pool_float_5)                                         \
-    FN(avg_pool_float_5_relaxed)                                 \
-    FN(avg_pool_quant8_1)                                        \
-    FN(avg_pool_quant8_2)                                        \
-    FN(avg_pool_quant8_3)                                        \
-    FN(avg_pool_quant8_4)                                        \
-    FN(avg_pool_quant8_5)                                        \
-    FN(batch_to_space)                                           \
-    FN(batch_to_space_float_1)                                   \
-    FN(batch_to_space_float_1_relaxed)                           \
-    FN(batch_to_space_quant8_1)                                  \
-    FN(batch_to_space_relaxed)                                   \
-    FN(concat_float_1)                                           \
-    FN(concat_float_1_relaxed)                                   \
-    FN(concat_float_2)                                           \
-    FN(concat_float_2_relaxed)                                   \
-    FN(concat_float_3)                                           \
-    FN(concat_float_3_relaxed)                                   \
-    FN(concat_quant8_1)                                          \
-    FN(concat_quant8_2)                                          \
-    FN(concat_quant8_3)                                          \
-    FN(conv_1_h3_w2_SAME)                                        \
-    FN(conv_1_h3_w2_SAME_relaxed)                                \
-    FN(conv_1_h3_w2_VALID)                                       \
-    FN(conv_1_h3_w2_VALID_relaxed)                               \
-    FN(conv_3_h3_w2_SAME)                                        \
-    FN(conv_3_h3_w2_SAME_relaxed)                                \
-    FN(conv_3_h3_w2_VALID)                                       \
-    FN(conv_3_h3_w2_VALID_relaxed)                               \
-    FN(conv_float)                                               \
-    FN(conv_float_2)                                             \
-    FN(conv_float_2_relaxed)                                     \
-    FN(conv_float_channels)                                      \
-    FN(conv_float_channels_relaxed)                              \
-    FN(conv_float_channels_weights_as_inputs)                    \
-    FN(conv_float_channels_weights_as_inputs_relaxed)            \
-    FN(conv_float_large)                                         \
-    FN(conv_float_large_relaxed)                                 \
-    FN(conv_float_large_weights_as_inputs)                       \
-    FN(conv_float_large_weights_as_inputs_relaxed)               \
-    FN(conv_float_relaxed)                                       \
-    FN(conv_float_weights_as_inputs)                             \
-    FN(conv_float_weights_as_inputs_relaxed)                     \
-    FN(conv_quant8)                                              \
-    FN(conv_quant8_2)                                            \
-    FN(conv_quant8_channels)                                     \
-    FN(conv_quant8_channels_weights_as_inputs)                   \
-    FN(conv_quant8_large)                                        \
-    FN(conv_quant8_large_weights_as_inputs)                      \
-    FN(conv_quant8_overflow)                                     \
-    FN(conv_quant8_overflow_weights_as_inputs)                   \
-    FN(conv_quant8_weights_as_inputs)                            \
-    FN(depth_to_space_float_1)                                   \
-    FN(depth_to_space_float_1_relaxed)                           \
-    FN(depth_to_space_float_2)                                   \
-    FN(depth_to_space_float_2_relaxed)                           \
-    FN(depth_to_space_float_3)                                   \
-    FN(depth_to_space_float_3_relaxed)                           \
-    FN(depth_to_space_quant8_1)                                  \
-    FN(depth_to_space_quant8_2)                                  \
-    FN(depthwise_conv)                                           \
-    FN(depthwise_conv2d_float)                                   \
-    FN(depthwise_conv2d_float_2)                                 \
-    FN(depthwise_conv2d_float_2_relaxed)                         \
-    FN(depthwise_conv2d_float_large)                             \
-    FN(depthwise_conv2d_float_large_2)                           \
-    FN(depthwise_conv2d_float_large_2_relaxed)                   \
-    FN(depthwise_conv2d_float_large_2_weights_as_inputs)         \
-    FN(depthwise_conv2d_float_large_2_weights_as_inputs_relaxed) \
-    FN(depthwise_conv2d_float_large_relaxed)                     \
-    FN(depthwise_conv2d_float_large_weights_as_inputs)           \
-    FN(depthwise_conv2d_float_large_weights_as_inputs_relaxed)   \
-    FN(depthwise_conv2d_float_relaxed)                           \
-    FN(depthwise_conv2d_float_weights_as_inputs)                 \
-    FN(depthwise_conv2d_float_weights_as_inputs_relaxed)         \
-    FN(depthwise_conv2d_quant8)                                  \
-    FN(depthwise_conv2d_quant8_2)                                \
-    FN(depthwise_conv2d_quant8_large)                            \
-    FN(depthwise_conv2d_quant8_large_weights_as_inputs)          \
-    FN(depthwise_conv2d_quant8_weights_as_inputs)                \
-    FN(depthwise_conv_relaxed)                                   \
-    FN(dequantize)                                               \
-    FN(dequantize_relaxed)                                       \
-    FN(div)                                                      \
-    FN(div_broadcast_float)                                      \
-    FN(div_broadcast_float_relaxed)                              \
-    FN(div_relaxed)                                              \
-    FN(embedding_lookup)                                         \
-    FN(embedding_lookup_relaxed)                                 \
-    FN(floor)                                                    \
-    FN(floor_relaxed)                                            \
-    FN(fully_connected_float)                                    \
-    FN(fully_connected_float_2)                                  \
-    FN(fully_connected_float_2_relaxed)                          \
-    FN(fully_connected_float_4d_simple)                          \
-    FN(fully_connected_float_4d_simple_relaxed)                  \
-    FN(fully_connected_float_large)                              \
-    FN(fully_connected_float_large_relaxed)                      \
-    FN(fully_connected_float_large_weights_as_inputs)            \
-    FN(fully_connected_float_large_weights_as_inputs_relaxed)    \
-    FN(fully_connected_float_relaxed)                            \
-    FN(fully_connected_float_weights_as_inputs)                  \
-    FN(fully_connected_float_weights_as_inputs_relaxed)          \
-    FN(fully_connected_quant8)                                   \
-    FN(fully_connected_quant8_2)                                 \
-    FN(fully_connected_quant8_large)                             \
-    FN(fully_connected_quant8_large_weights_as_inputs)           \
-    FN(fully_connected_quant8_weights_as_inputs)                 \
-    FN(hashtable_lookup_float)                                   \
-    FN(hashtable_lookup_float_relaxed)                           \
-    FN(hashtable_lookup_quant8)                                  \
-    FN(l2_normalization)                                         \
-    FN(l2_normalization_2)                                       \
-    FN(l2_normalization_2_relaxed)                               \
-    FN(l2_normalization_large)                                   \
-    FN(l2_normalization_large_relaxed)                           \
-    FN(l2_normalization_relaxed)                                 \
-    FN(l2_pool_float)                                            \
-    FN(l2_pool_float_2)                                          \
-    FN(l2_pool_float_2_relaxed)                                  \
-    FN(l2_pool_float_large)                                      \
-    FN(l2_pool_float_large_relaxed)                              \
-    FN(l2_pool_float_relaxed)                                    \
-    FN(local_response_norm_float_1)                              \
-    FN(local_response_norm_float_1_relaxed)                      \
-    FN(local_response_norm_float_2)                              \
-    FN(local_response_norm_float_2_relaxed)                      \
-    FN(local_response_norm_float_3)                              \
-    FN(local_response_norm_float_3_relaxed)                      \
-    FN(local_response_norm_float_4)                              \
-    FN(local_response_norm_float_4_relaxed)                      \
-    FN(logistic_float_1)                                         \
-    FN(logistic_float_1_relaxed)                                 \
-    FN(logistic_float_2)                                         \
-    FN(logistic_float_2_relaxed)                                 \
-    FN(logistic_quant8_1)                                        \
-    FN(logistic_quant8_2)                                        \
-    FN(lsh_projection)                                           \
-    FN(lsh_projection_2)                                         \
-    FN(lsh_projection_2_relaxed)                                 \
-    FN(lsh_projection_relaxed)                                   \
-    FN(lsh_projection_weights_as_inputs)                         \
-    FN(lsh_projection_weights_as_inputs_relaxed)                 \
-    FN(lstm)                                                     \
-    FN(lstm2)                                                    \
-    FN(lstm2_relaxed)                                            \
-    FN(lstm2_state)                                              \
-    FN(lstm2_state2)                                             \
-    FN(lstm2_state2_relaxed)                                     \
-    FN(lstm2_state_relaxed)                                      \
-    FN(lstm3)                                                    \
-    FN(lstm3_relaxed)                                            \
-    FN(lstm3_state)                                              \
-    FN(lstm3_state2)                                             \
-    FN(lstm3_state2_relaxed)                                     \
-    FN(lstm3_state3)                                             \
-    FN(lstm3_state3_relaxed)                                     \
-    FN(lstm3_state_relaxed)                                      \
-    FN(lstm_relaxed)                                             \
-    FN(lstm_state)                                               \
-    FN(lstm_state2)                                              \
-    FN(lstm_state2_relaxed)                                      \
-    FN(lstm_state_relaxed)                                       \
-    FN(max_pool_float_1)                                         \
-    FN(max_pool_float_1_relaxed)                                 \
-    FN(max_pool_float_2)                                         \
-    FN(max_pool_float_2_relaxed)                                 \
-    FN(max_pool_float_3)                                         \
-    FN(max_pool_float_3_relaxed)                                 \
-    FN(max_pool_float_4)                                         \
-    FN(max_pool_float_4_relaxed)                                 \
-    FN(max_pool_quant8_1)                                        \
-    FN(max_pool_quant8_2)                                        \
-    FN(max_pool_quant8_3)                                        \
-    FN(max_pool_quant8_4)                                        \
-    FN(mean)                                                     \
-    FN(mean_float_1)                                             \
-    FN(mean_float_1_relaxed)                                     \
-    FN(mean_float_2)                                             \
-    FN(mean_float_2_relaxed)                                     \
-    FN(mean_quant8_1)                                            \
-    FN(mean_quant8_2)                                            \
-    FN(mean_relaxed)                                             \
-    FN(mobilenet_224_gender_basic_fixed)                         \
-    FN(mobilenet_224_gender_basic_fixed_relaxed)                 \
-    FN(mobilenet_quantized)                                      \
-    FN(mul)                                                      \
-    FN(mul_broadcast_quant8)                                     \
-    FN(mul_quant8)                                               \
-    FN(mul_relaxed)                                              \
-    FN(mul_relu)                                                 \
-    FN(mul_relu_relaxed)                                         \
-    FN(pad)                                                      \
-    FN(pad_float_1)                                              \
-    FN(pad_float_1_relaxed)                                      \
-    FN(pad_relaxed)                                              \
-    FN(relu1_float_1)                                            \
-    FN(relu1_float_1_relaxed)                                    \
-    FN(relu1_float_2)                                            \
-    FN(relu1_float_2_relaxed)                                    \
-    FN(relu1_quant8_1)                                           \
-    FN(relu1_quant8_2)                                           \
-    FN(relu6_float_1)                                            \
-    FN(relu6_float_1_relaxed)                                    \
-    FN(relu6_float_2)                                            \
-    FN(relu6_float_2_relaxed)                                    \
-    FN(relu6_quant8_1)                                           \
-    FN(relu6_quant8_2)                                           \
-    FN(relu_float_1)                                             \
-    FN(relu_float_1_relaxed)                                     \
-    FN(relu_float_2)                                             \
-    FN(relu_float_2_relaxed)                                     \
-    FN(relu_quant8_1)                                            \
-    FN(relu_quant8_2)                                            \
-    FN(reshape)                                                  \
-    FN(reshape_quant8)                                           \
-    FN(reshape_quant8_weights_as_inputs)                         \
-    FN(reshape_relaxed)                                          \
-    FN(reshape_weights_as_inputs)                                \
-    FN(reshape_weights_as_inputs_relaxed)                        \
-    FN(resize_bilinear)                                          \
-    FN(resize_bilinear_2)                                        \
-    FN(resize_bilinear_2_relaxed)                                \
-    FN(resize_bilinear_relaxed)                                  \
-    FN(rnn)                                                      \
-    FN(rnn_relaxed)                                              \
-    FN(rnn_state)                                                \
-    FN(rnn_state_relaxed)                                        \
-    FN(softmax_float_1)                                          \
-    FN(softmax_float_1_relaxed)                                  \
-    FN(softmax_float_2)                                          \
-    FN(softmax_float_2_relaxed)                                  \
-    FN(softmax_quant8_1)                                         \
-    FN(softmax_quant8_2)                                         \
-    FN(space_to_batch)                                           \
-    FN(space_to_batch_float_1)                                   \
-    FN(space_to_batch_float_1_relaxed)                           \
-    FN(space_to_batch_float_2)                                   \
-    FN(space_to_batch_float_2_relaxed)                           \
-    FN(space_to_batch_float_3)                                   \
-    FN(space_to_batch_float_3_relaxed)                           \
-    FN(space_to_batch_quant8_1)                                  \
-    FN(space_to_batch_quant8_2)                                  \
-    FN(space_to_batch_quant8_3)                                  \
-    FN(space_to_batch_relaxed)                                   \
-    FN(space_to_depth_float_1)                                   \
-    FN(space_to_depth_float_1_relaxed)                           \
-    FN(space_to_depth_float_2)                                   \
-    FN(space_to_depth_float_2_relaxed)                           \
-    FN(space_to_depth_float_3)                                   \
-    FN(space_to_depth_float_3_relaxed)                           \
-    FN(space_to_depth_quant8_1)                                  \
-    FN(space_to_depth_quant8_2)                                  \
-    FN(squeeze)                                                  \
-    FN(squeeze_float_1)                                          \
-    FN(squeeze_float_1_relaxed)                                  \
-    FN(squeeze_quant8_1)                                         \
-    FN(squeeze_relaxed)                                          \
-    FN(strided_slice)                                            \
-    FN(strided_slice_float_1)                                    \
-    FN(strided_slice_float_10)                                   \
-    FN(strided_slice_float_10_relaxed)                           \
-    FN(strided_slice_float_11)                                   \
-    FN(strided_slice_float_11_relaxed)                           \
-    FN(strided_slice_float_1_relaxed)                            \
-    FN(strided_slice_float_2)                                    \
-    FN(strided_slice_float_2_relaxed)                            \
-    FN(strided_slice_float_3)                                    \
-    FN(strided_slice_float_3_relaxed)                            \
-    FN(strided_slice_float_4)                                    \
-    FN(strided_slice_float_4_relaxed)                            \
-    FN(strided_slice_float_5)                                    \
-    FN(strided_slice_float_5_relaxed)                            \
-    FN(strided_slice_float_6)                                    \
-    FN(strided_slice_float_6_relaxed)                            \
-    FN(strided_slice_float_7)                                    \
-    FN(strided_slice_float_7_relaxed)                            \
-    FN(strided_slice_float_8)                                    \
-    FN(strided_slice_float_8_relaxed)                            \
-    FN(strided_slice_float_9)                                    \
-    FN(strided_slice_float_9_relaxed)                            \
-    FN(strided_slice_qaunt8_10)                                  \
-    FN(strided_slice_qaunt8_11)                                  \
-    FN(strided_slice_quant8_1)                                   \
-    FN(strided_slice_quant8_2)                                   \
-    FN(strided_slice_quant8_3)                                   \
-    FN(strided_slice_quant8_4)                                   \
-    FN(strided_slice_quant8_5)                                   \
-    FN(strided_slice_quant8_6)                                   \
-    FN(strided_slice_quant8_7)                                   \
-    FN(strided_slice_quant8_8)                                   \
-    FN(strided_slice_quant8_9)                                   \
-    FN(strided_slice_relaxed)                                    \
-    FN(sub)                                                      \
-    FN(sub_broadcast_float)                                      \
-    FN(sub_broadcast_float_relaxed)                              \
-    FN(sub_relaxed)                                              \
-    FN(svdf)                                                     \
-    FN(svdf2)                                                    \
-    FN(svdf2_relaxed)                                            \
-    FN(svdf_relaxed)                                             \
-    FN(svdf_state)                                               \
-    FN(svdf_state_relaxed)                                       \
-    FN(tanh)                                                     \
-    FN(tanh_relaxed)                                             \
-    FN(transpose)                                                \
-    FN(transpose_float_1)                                        \
-    FN(transpose_float_1_relaxed)                                \
-    FN(transpose_quant8_1)                                       \
-    FN(transpose_relaxed)
-
-#define FORWARD_DECLARE_GENERATED_OBJECTS(function) \
-    namespace function {                            \
-    extern std::vector<MixedTypedExample> examples; \
-    Model createTestModel();                        \
-    }
-
-FOR_EACH_TEST_MODEL(FORWARD_DECLARE_GENERATED_OBJECTS)
-
-#undef FORWARD_DECLARE_GENERATED_OBJECTS
-
-}  // namespace functional
-}  // namespace vts
-}  // namespace V1_1
-}  // namespace neuralnetworks
-}  // namespace hardware
-}  // namespace android
-
-#endif  // VTS_HAL_NEURALNETWORKS_V1_1_VTS_FUNCTIONAL_MODELS_H
diff --git a/neuralnetworks/1.1/vts/functional/ValidationTests.cpp b/neuralnetworks/1.1/vts/functional/ValidationTests.cpp
deleted file mode 100644
index 1c35ba8..0000000
--- a/neuralnetworks/1.1/vts/functional/ValidationTests.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2018 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 "neuralnetworks_hidl_hal_test"
-
-#include "Models.h"
-#include "VtsHalNeuralnetworks.h"
-
-namespace android {
-namespace hardware {
-namespace neuralnetworks {
-namespace V1_1 {
-namespace vts {
-namespace functional {
-
-// forward declarations
-std::vector<Request> createRequests(const std::vector<MixedTypedExample>& examples);
-
-// generate validation tests
-#define VTS_CURRENT_TEST_CASE(TestName)                                           \
-    TEST_F(ValidationTest, TestName) {                                            \
-        const Model model = TestName::createTestModel();                          \
-        const std::vector<Request> requests = createRequests(TestName::examples); \
-        validateModel(model);                                                     \
-        validateRequests(model, requests);                                        \
-    }
-
-FOR_EACH_TEST_MODEL(VTS_CURRENT_TEST_CASE)
-
-#undef VTS_CURRENT_TEST_CASE
-
-}  // namespace functional
-}  // namespace vts
-}  // namespace V1_1
-}  // namespace neuralnetworks
-}  // namespace hardware
-}  // namespace android
diff --git a/neuralnetworks/1.2/Android.bp b/neuralnetworks/1.2/Android.bp
index 5a661e0..e155bbd 100644
--- a/neuralnetworks/1.2/Android.bp
+++ b/neuralnetworks/1.2/Android.bp
@@ -19,8 +19,10 @@
         "Model",
         "Operand",
         "OperandType",
+        "OperandTypeRange",
         "Operation",
         "OperationType",
+        "OperationTypeRange",
     ],
     gen_java: false,
 }
diff --git a/neuralnetworks/1.2/types.hal b/neuralnetworks/1.2/types.hal
index 4a1e7a8..45476ee 100644
--- a/neuralnetworks/1.2/types.hal
+++ b/neuralnetworks/1.2/types.hal
@@ -33,17 +33,38 @@
     /**
      * A tensor of 16 bit signed integers that represent real numbers.
      *
-     * Attached to this tensor are two numbers that are used to convert the 16
-     * bit integer to the real value and vice versa. These two numbers are:
-     * - scale: a 32 bit floating point value greater than zero.
-     * - zeroPoint: a 32 bit integer, in range [-32768, 32767].
+     * Attached to this tensor is a number representing real value scale that is
+     * used to convert the 16 bit number to a real value in the following way:
+     * realValue = integerValue * scale.
      *
-     * The formula is:
-     * realValue = (integerValue - zeroPoint) * scale.
+     * scale is a 32 bit floating point with value greater then zero.
      */
-    TENSOR_QUANT16_ASYMM = 7,
+    TENSOR_QUANT16_SYMM = 7,
     /** A tensor of 16 bit floating point values. */
     TENSOR_FLOAT16 = 8,
+    /**
+     * A tensor of 8 bit boolean values.
+     *
+     * Values of this operand type are either true or false. A zero value
+     * represents false; any other value represents true.
+     */
+    TENSOR_BOOL8 = 9,
+    /* ADDING A NEW FUNDAMENTAL TYPE REQUIRES UPDATING THE VALUE OF
+     * OperandTypeRange::OPERAND_FUNDAMENTAL_MAX.
+     */
+    /* ADDING A NEW OEM TYPE REQUIRES UPDATING THE VALUE OF
+     * OperandTypeRange::OPERAND_OEM_MAX.
+     */
+};
+
+/**
+ * The range of operand values in the OperandType enum.
+ */
+enum OperandTypeRange : uint32_t {
+    OPERAND_FUNDAMENTAL_MIN = 0,
+    OPERAND_FUNDAMENTAL_MAX = 9,
+    OPERAND_OEM_MIN     = 10000,
+    OPERAND_OEM_MAX     = 10001,
 };
 
 /**
@@ -103,6 +124,26 @@
     UNIDIRECTIONAL_SEQUENCE_LSTM = 85,
     UNIDIRECTIONAL_SEQUENCE_RNN = 86,
     ROTATED_BBOX_TRANSFORM = 87,
+    ABS = 88,
+    ROI_POOLING = 89,
+    EQUAL = 90,
+    NOT_EQUAL = 91,
+    /* ADDING A NEW FUNDAMENTAL OPERATION REQUIRES UPDATING THE VALUE OF
+     * OperationTypeRange::OPERATION_FUNDAMENTAL_MAX.
+     */
+    /* ADDING A NEW OEM OPERATION REQUIRES UPDATING THE VALUE OF
+     * OperationTypeRange::OPERATION_OEM_MAX.
+     */
+};
+
+/**
+ * The range of values in the OperationType enum.
+ */
+enum OperationTypeRange : uint32_t {
+    OPERATION_FUNDAMENTAL_MIN = 0,
+    OPERATION_FUNDAMENTAL_MAX = 91,
+    OPERATION_OEM_MIN = 10000,
+    OPERATION_OEM_MAX = 10000,
 };
 
 /**
diff --git a/neuralnetworks/1.2/vts/functional/Android.bp b/neuralnetworks/1.2/vts/functional/Android.bp
index 09d0dc3..5b119ee 100644
--- a/neuralnetworks/1.2/vts/functional/Android.bp
+++ b/neuralnetworks/1.2/vts/functional/Android.bp
@@ -14,40 +14,33 @@
 // limitations under the License.
 //
 
+// Tests for V1_0 models using the V1_2 HAL.
+cc_test {
+    name: "VtsHalNeuralnetworksV1_2CompatV1_0TargetTest",
+    defaults: ["VtsHalNeuralNetworksTargetTestDefaults"],
+    srcs: [
+        "GeneratedTestsV1_0.cpp",
+    ],
+    test_suites: ["general-tests"],
+}
+
+// Tests for V1_1 models using the V1_2 HAL.
+cc_test {
+    name: "VtsHalNeuralnetworksV1_2CompatV1_1TargetTest",
+    defaults: ["VtsHalNeuralNetworksTargetTestDefaults"],
+    srcs: [
+        "GeneratedTestsV1_1.cpp",
+    ],
+    test_suites: ["general-tests"],
+}
+
+// Tests for V1_2 models.
 cc_test {
     name: "VtsHalNeuralnetworksV1_2TargetTest",
+    defaults: ["VtsHalNeuralNetworksTargetTestDefaults"],
     srcs: [
         "BasicTests.cpp",
         "GeneratedTests.cpp",
-        "ValidateModel.cpp",
-        "ValidateRequest.cpp",
-        "ValidationTests.cpp",
-        "VtsHalNeuralnetworks.cpp",
     ],
-    defaults: ["VtsHalTargetTestDefaults"],
-    static_libs: [
-        "android.hardware.neuralnetworks@1.0",
-        "android.hardware.neuralnetworks@1.1",
-        "android.hardware.neuralnetworks@1.2",
-        "android.hidl.allocator@1.0",
-        "android.hidl.memory@1.0",
-        "libgmock",
-        "libhidlmemory",
-        "libneuralnetworks_utils",
-        "VtsHalNeuralnetworksTest_utils",
-    ],
-    header_libs: [
-        "libneuralnetworks_headers",
-        "libneuralnetworks_generated_test_harness_headers",
-        "libneuralnetworks_generated_tests",
-    ],
-    // Bug: http://b/74200014 - Disable arm32 asan since it triggers internal
-    // error in ld.gold.
-    arch: {
-        arm: {
-            sanitize: {
-                never: true,
-            },
-        },
-    },
+    test_suites: ["general-tests"],
 }
diff --git a/neuralnetworks/1.2/vts/functional/GeneratedTests.cpp b/neuralnetworks/1.2/vts/functional/GeneratedTests.cpp
index e87fa6b..79d5a60 100644
--- a/neuralnetworks/1.2/vts/functional/GeneratedTests.cpp
+++ b/neuralnetworks/1.2/vts/functional/GeneratedTests.cpp
@@ -45,9 +45,9 @@
 using ::android::nn::allocateSharedMemory;
 using ::test_helper::MixedTypedExample;
 
+std::vector<Request> createRequests(const std::vector<MixedTypedExample>& examples);
+
 // in frameworks/ml/nn/runtime/tests/generated/
-#include "all_generated_V1_0_vts_tests.cpp"
-#include "all_generated_V1_1_vts_tests.cpp"
 #include "all_generated_V1_2_vts_tests.cpp"
 
 }  // namespace functional
diff --git a/neuralnetworks/1.2/vts/functional/GeneratedTestsV1_0.cpp b/neuralnetworks/1.2/vts/functional/GeneratedTestsV1_0.cpp
new file mode 100644
index 0000000..42e22b0
--- /dev/null
+++ b/neuralnetworks/1.2/vts/functional/GeneratedTestsV1_0.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2018 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 "neuralnetworks_hidl_hal_test"
+
+#include "VtsHalNeuralnetworks.h"
+
+#include "Callbacks.h"
+#include "TestHarness.h"
+#include "Utils.h"
+
+#include <android-base/logging.h>
+#include <android/hidl/memory/1.0/IMemory.h>
+#include <hidlmemory/mapping.h>
+
+namespace android {
+namespace hardware {
+namespace neuralnetworks {
+
+namespace generated_tests {
+using ::test_helper::MixedTypedExample;
+extern void Execute(const sp<V1_2::IDevice>&, std::function<V1_2::Model(void)>,
+                    std::function<bool(int)>, const std::vector<MixedTypedExample>&);
+}  // namespace generated_tests
+
+namespace V1_2 {
+namespace vts {
+namespace functional {
+
+using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
+using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
+using ::android::nn::allocateSharedMemory;
+using ::test_helper::MixedTypedExample;
+
+std::vector<Request> createRequests(const std::vector<MixedTypedExample>& examples);
+
+// in frameworks/ml/nn/runtime/tests/generated/
+#include "all_generated_V1_0_vts_tests.cpp"
+
+}  // namespace functional
+}  // namespace vts
+}  // namespace V1_2
+}  // namespace neuralnetworks
+}  // namespace hardware
+}  // namespace android
diff --git a/neuralnetworks/1.2/vts/functional/GeneratedTestsV1_1.cpp b/neuralnetworks/1.2/vts/functional/GeneratedTestsV1_1.cpp
new file mode 100644
index 0000000..aab5cb6
--- /dev/null
+++ b/neuralnetworks/1.2/vts/functional/GeneratedTestsV1_1.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2018 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 "neuralnetworks_hidl_hal_test"
+
+#include "VtsHalNeuralnetworks.h"
+
+#include "Callbacks.h"
+#include "TestHarness.h"
+#include "Utils.h"
+
+#include <android-base/logging.h>
+#include <android/hidl/memory/1.0/IMemory.h>
+#include <hidlmemory/mapping.h>
+
+namespace android {
+namespace hardware {
+namespace neuralnetworks {
+
+namespace generated_tests {
+using ::test_helper::MixedTypedExample;
+extern void Execute(const sp<V1_2::IDevice>&, std::function<V1_2::Model(void)>,
+                    std::function<bool(int)>, const std::vector<MixedTypedExample>&);
+}  // namespace generated_tests
+
+namespace V1_2 {
+namespace vts {
+namespace functional {
+
+using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
+using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
+using ::android::nn::allocateSharedMemory;
+using ::test_helper::MixedTypedExample;
+
+std::vector<Request> createRequests(const std::vector<MixedTypedExample>& examples);
+
+// in frameworks/ml/nn/runtime/tests/generated/
+#include "all_generated_V1_1_vts_tests.cpp"
+
+}  // namespace functional
+}  // namespace vts
+}  // namespace V1_2
+}  // namespace neuralnetworks
+}  // namespace hardware
+}  // namespace android
diff --git a/neuralnetworks/1.2/vts/functional/Models.h b/neuralnetworks/1.2/vts/functional/Models.h
deleted file mode 100644
index 2d512fe..0000000
--- a/neuralnetworks/1.2/vts/functional/Models.h
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * Copyright (C) 2018 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 VTS_HAL_NEURALNETWORKS_V1_2_VTS_FUNCTIONAL_MODELS_H
-#define VTS_HAL_NEURALNETWORKS_V1_2_VTS_FUNCTIONAL_MODELS_H
-
-#define LOG_TAG "neuralnetworks_hidl_hal_test"
-
-#include "TestHarness.h"
-
-#include <android/hardware/neuralnetworks/1.0/types.h>
-#include <android/hardware/neuralnetworks/1.1/types.h>
-#include <android/hardware/neuralnetworks/1.2/types.h>
-
-namespace android {
-namespace hardware {
-namespace neuralnetworks {
-namespace V1_2 {
-namespace vts {
-namespace functional {
-
-using MixedTypedExample = test_helper::MixedTypedExample;
-
-#define FOR_EACH_TEST_MODEL(FN)                                  \
-    FN(add)                                                      \
-    FN(add_broadcast_quant8)                                     \
-    FN(add_quant8)                                               \
-    FN(add_relaxed)                                              \
-    FN(avg_pool_float_1)                                         \
-    FN(avg_pool_float_1_relaxed)                                 \
-    FN(avg_pool_float_2)                                         \
-    FN(avg_pool_float_2_relaxed)                                 \
-    FN(avg_pool_float_3)                                         \
-    FN(avg_pool_float_3_relaxed)                                 \
-    FN(avg_pool_float_4)                                         \
-    FN(avg_pool_float_4_relaxed)                                 \
-    FN(avg_pool_float_5)                                         \
-    FN(avg_pool_float_5_relaxed)                                 \
-    FN(avg_pool_quant8_1)                                        \
-    FN(avg_pool_quant8_2)                                        \
-    FN(avg_pool_quant8_3)                                        \
-    FN(avg_pool_quant8_4)                                        \
-    FN(avg_pool_quant8_5)                                        \
-    FN(batch_to_space)                                           \
-    FN(batch_to_space_float_1)                                   \
-    FN(batch_to_space_float_1_relaxed)                           \
-    FN(batch_to_space_quant8_1)                                  \
-    FN(batch_to_space_relaxed)                                   \
-    FN(concat_float_1)                                           \
-    FN(concat_float_1_relaxed)                                   \
-    FN(concat_float_2)                                           \
-    FN(concat_float_2_relaxed)                                   \
-    FN(concat_float_3)                                           \
-    FN(concat_float_3_relaxed)                                   \
-    FN(concat_quant8_1)                                          \
-    FN(concat_quant8_2)                                          \
-    FN(concat_quant8_3)                                          \
-    FN(conv_1_h3_w2_SAME)                                        \
-    FN(conv_1_h3_w2_SAME_relaxed)                                \
-    FN(conv_1_h3_w2_VALID)                                       \
-    FN(conv_1_h3_w2_VALID_relaxed)                               \
-    FN(conv_3_h3_w2_SAME)                                        \
-    FN(conv_3_h3_w2_SAME_relaxed)                                \
-    FN(conv_3_h3_w2_VALID)                                       \
-    FN(conv_3_h3_w2_VALID_relaxed)                               \
-    FN(conv_float)                                               \
-    FN(conv_float_2)                                             \
-    FN(conv_float_2_relaxed)                                     \
-    FN(conv_float_channels)                                      \
-    FN(conv_float_channels_relaxed)                              \
-    FN(conv_float_channels_weights_as_inputs)                    \
-    FN(conv_float_channels_weights_as_inputs_relaxed)            \
-    FN(conv_float_large)                                         \
-    FN(conv_float_large_relaxed)                                 \
-    FN(conv_float_large_weights_as_inputs)                       \
-    FN(conv_float_large_weights_as_inputs_relaxed)               \
-    FN(conv_float_relaxed)                                       \
-    FN(conv_float_weights_as_inputs)                             \
-    FN(conv_float_weights_as_inputs_relaxed)                     \
-    FN(conv_quant8)                                              \
-    FN(conv_quant8_2)                                            \
-    FN(conv_quant8_channels)                                     \
-    FN(conv_quant8_channels_weights_as_inputs)                   \
-    FN(conv_quant8_large)                                        \
-    FN(conv_quant8_large_weights_as_inputs)                      \
-    FN(conv_quant8_overflow)                                     \
-    FN(conv_quant8_overflow_weights_as_inputs)                   \
-    FN(conv_quant8_weights_as_inputs)                            \
-    FN(depth_to_space_float_1)                                   \
-    FN(depth_to_space_float_1_relaxed)                           \
-    FN(depth_to_space_float_2)                                   \
-    FN(depth_to_space_float_2_relaxed)                           \
-    FN(depth_to_space_float_3)                                   \
-    FN(depth_to_space_float_3_relaxed)                           \
-    FN(depth_to_space_quant8_1)                                  \
-    FN(depth_to_space_quant8_2)                                  \
-    FN(depthwise_conv)                                           \
-    FN(depthwise_conv2d_float)                                   \
-    FN(depthwise_conv2d_float_2)                                 \
-    FN(depthwise_conv2d_float_2_relaxed)                         \
-    FN(depthwise_conv2d_float_large)                             \
-    FN(depthwise_conv2d_float_large_2)                           \
-    FN(depthwise_conv2d_float_large_2_relaxed)                   \
-    FN(depthwise_conv2d_float_large_2_weights_as_inputs)         \
-    FN(depthwise_conv2d_float_large_2_weights_as_inputs_relaxed) \
-    FN(depthwise_conv2d_float_large_relaxed)                     \
-    FN(depthwise_conv2d_float_large_weights_as_inputs)           \
-    FN(depthwise_conv2d_float_large_weights_as_inputs_relaxed)   \
-    FN(depthwise_conv2d_float_relaxed)                           \
-    FN(depthwise_conv2d_float_weights_as_inputs)                 \
-    FN(depthwise_conv2d_float_weights_as_inputs_relaxed)         \
-    FN(depthwise_conv2d_quant8)                                  \
-    FN(depthwise_conv2d_quant8_2)                                \
-    FN(depthwise_conv2d_quant8_large)                            \
-    FN(depthwise_conv2d_quant8_large_weights_as_inputs)          \
-    FN(depthwise_conv2d_quant8_weights_as_inputs)                \
-    FN(depthwise_conv_relaxed)                                   \
-    FN(dequantize)                                               \
-    FN(dequantize_relaxed)                                       \
-    FN(div)                                                      \
-    FN(div_broadcast_float)                                      \
-    FN(div_broadcast_float_relaxed)                              \
-    FN(div_relaxed)                                              \
-    FN(embedding_lookup)                                         \
-    FN(embedding_lookup_relaxed)                                 \
-    FN(floor)                                                    \
-    FN(floor_relaxed)                                            \
-    FN(fully_connected_float)                                    \
-    FN(fully_connected_float_2)                                  \
-    FN(fully_connected_float_2_relaxed)                          \
-    FN(fully_connected_float_4d_simple)                          \
-    FN(fully_connected_float_4d_simple_relaxed)                  \
-    FN(fully_connected_float_large)                              \
-    FN(fully_connected_float_large_relaxed)                      \
-    FN(fully_connected_float_large_weights_as_inputs)            \
-    FN(fully_connected_float_large_weights_as_inputs_relaxed)    \
-    FN(fully_connected_float_relaxed)                            \
-    FN(fully_connected_float_weights_as_inputs)                  \
-    FN(fully_connected_float_weights_as_inputs_relaxed)          \
-    FN(fully_connected_quant8)                                   \
-    FN(fully_connected_quant8_2)                                 \
-    FN(fully_connected_quant8_large)                             \
-    FN(fully_connected_quant8_large_weights_as_inputs)           \
-    FN(fully_connected_quant8_weights_as_inputs)                 \
-    FN(hashtable_lookup_float)                                   \
-    FN(hashtable_lookup_float_relaxed)                           \
-    FN(hashtable_lookup_quant8)                                  \
-    FN(l2_normalization)                                         \
-    FN(l2_normalization_2)                                       \
-    FN(l2_normalization_2_relaxed)                               \
-    FN(l2_normalization_large)                                   \
-    FN(l2_normalization_large_relaxed)                           \
-    FN(l2_normalization_relaxed)                                 \
-    FN(l2_pool_float)                                            \
-    FN(l2_pool_float_2)                                          \
-    FN(l2_pool_float_2_relaxed)                                  \
-    FN(l2_pool_float_large)                                      \
-    FN(l2_pool_float_large_relaxed)                              \
-    FN(l2_pool_float_relaxed)                                    \
-    FN(local_response_norm_float_1)                              \
-    FN(local_response_norm_float_1_relaxed)                      \
-    FN(local_response_norm_float_2)                              \
-    FN(local_response_norm_float_2_relaxed)                      \
-    FN(local_response_norm_float_3)                              \
-    FN(local_response_norm_float_3_relaxed)                      \
-    FN(local_response_norm_float_4)                              \
-    FN(local_response_norm_float_4_relaxed)                      \
-    FN(logistic_float_1)                                         \
-    FN(logistic_float_1_relaxed)                                 \
-    FN(logistic_float_2)                                         \
-    FN(logistic_float_2_relaxed)                                 \
-    FN(logistic_quant8_1)                                        \
-    FN(logistic_quant8_2)                                        \
-    FN(lsh_projection)                                           \
-    FN(lsh_projection_2)                                         \
-    FN(lsh_projection_2_relaxed)                                 \
-    FN(lsh_projection_relaxed)                                   \
-    FN(lsh_projection_weights_as_inputs)                         \
-    FN(lsh_projection_weights_as_inputs_relaxed)                 \
-    FN(lstm)                                                     \
-    FN(lstm2)                                                    \
-    FN(lstm2_relaxed)                                            \
-    FN(lstm2_state)                                              \
-    FN(lstm2_state2)                                             \
-    FN(lstm2_state2_relaxed)                                     \
-    FN(lstm2_state_relaxed)                                      \
-    FN(lstm3)                                                    \
-    FN(lstm3_relaxed)                                            \
-    FN(lstm3_state)                                              \
-    FN(lstm3_state2)                                             \
-    FN(lstm3_state2_relaxed)                                     \
-    FN(lstm3_state3)                                             \
-    FN(lstm3_state3_relaxed)                                     \
-    FN(lstm3_state_relaxed)                                      \
-    FN(lstm_relaxed)                                             \
-    FN(lstm_state)                                               \
-    FN(lstm_state2)                                              \
-    FN(lstm_state2_relaxed)                                      \
-    FN(lstm_state_relaxed)                                       \
-    FN(max_pool_float_1)                                         \
-    FN(max_pool_float_1_relaxed)                                 \
-    FN(max_pool_float_2)                                         \
-    FN(max_pool_float_2_relaxed)                                 \
-    FN(max_pool_float_3)                                         \
-    FN(max_pool_float_3_relaxed)                                 \
-    FN(max_pool_float_4)                                         \
-    FN(max_pool_float_4_relaxed)                                 \
-    FN(max_pool_quant8_1)                                        \
-    FN(max_pool_quant8_2)                                        \
-    FN(max_pool_quant8_3)                                        \
-    FN(max_pool_quant8_4)                                        \
-    FN(mean)                                                     \
-    FN(mean_float_1)                                             \
-    FN(mean_float_1_relaxed)                                     \
-    FN(mean_float_2)                                             \
-    FN(mean_float_2_relaxed)                                     \
-    FN(mean_quant8_1)                                            \
-    FN(mean_quant8_2)                                            \
-    FN(mean_relaxed)                                             \
-    FN(mobilenet_224_gender_basic_fixed)                         \
-    FN(mobilenet_224_gender_basic_fixed_relaxed)                 \
-    FN(mobilenet_quantized)                                      \
-    FN(mul)                                                      \
-    FN(mul_broadcast_quant8)                                     \
-    FN(mul_quant8)                                               \
-    FN(mul_relaxed)                                              \
-    FN(mul_relu)                                                 \
-    FN(mul_relu_relaxed)                                         \
-    FN(pad)                                                      \
-    FN(pad_float_1)                                              \
-    FN(pad_float_1_relaxed)                                      \
-    FN(pad_relaxed)                                              \
-    FN(random_multinomial)                                       \
-    FN(relu1_float_1)                                            \
-    FN(relu1_float_1_relaxed)                                    \
-    FN(relu1_float_2)                                            \
-    FN(relu1_float_2_relaxed)                                    \
-    FN(relu1_quant8_1)                                           \
-    FN(relu1_quant8_2)                                           \
-    FN(relu6_float_1)                                            \
-    FN(relu6_float_1_relaxed)                                    \
-    FN(relu6_float_2)                                            \
-    FN(relu6_float_2_relaxed)                                    \
-    FN(relu6_quant8_1)                                           \
-    FN(relu6_quant8_2)                                           \
-    FN(relu_float_1)                                             \
-    FN(relu_float_1_relaxed)                                     \
-    FN(relu_float_2)                                             \
-    FN(relu_float_2_relaxed)                                     \
-    FN(relu_quant8_1)                                            \
-    FN(relu_quant8_2)                                            \
-    FN(reshape)                                                  \
-    FN(reshape_quant8)                                           \
-    FN(reshape_quant8_weights_as_inputs)                         \
-    FN(reshape_relaxed)                                          \
-    FN(reshape_weights_as_inputs)                                \
-    FN(reshape_weights_as_inputs_relaxed)                        \
-    FN(resize_bilinear)                                          \
-    FN(resize_bilinear_2)                                        \
-    FN(resize_bilinear_2_relaxed)                                \
-    FN(resize_bilinear_relaxed)                                  \
-    FN(rnn)                                                      \
-    FN(rnn_relaxed)                                              \
-    FN(rnn_state)                                                \
-    FN(rnn_state_relaxed)                                        \
-    FN(softmax_float_1)                                          \
-    FN(softmax_float_1_relaxed)                                  \
-    FN(softmax_float_2)                                          \
-    FN(softmax_float_2_relaxed)                                  \
-    FN(softmax_quant8_1)                                         \
-    FN(softmax_quant8_2)                                         \
-    FN(space_to_batch)                                           \
-    FN(space_to_batch_float_1)                                   \
-    FN(space_to_batch_float_1_relaxed)                           \
-    FN(space_to_batch_float_2)                                   \
-    FN(space_to_batch_float_2_relaxed)                           \
-    FN(space_to_batch_float_3)                                   \
-    FN(space_to_batch_float_3_relaxed)                           \
-    FN(space_to_batch_quant8_1)                                  \
-    FN(space_to_batch_quant8_2)                                  \
-    FN(space_to_batch_quant8_3)                                  \
-    FN(space_to_batch_relaxed)                                   \
-    FN(space_to_depth_float_1)                                   \
-    FN(space_to_depth_float_1_relaxed)                           \
-    FN(space_to_depth_float_2)                                   \
-    FN(space_to_depth_float_2_relaxed)                           \
-    FN(space_to_depth_float_3)                                   \
-    FN(space_to_depth_float_3_relaxed)                           \
-    FN(space_to_depth_quant8_1)                                  \
-    FN(space_to_depth_quant8_2)                                  \
-    FN(squeeze)                                                  \
-    FN(squeeze_float_1)                                          \
-    FN(squeeze_float_1_relaxed)                                  \
-    FN(squeeze_quant8_1)                                         \
-    FN(squeeze_relaxed)                                          \
-    FN(strided_slice)                                            \
-    FN(strided_slice_float_1)                                    \
-    FN(strided_slice_float_10)                                   \
-    FN(strided_slice_float_10_relaxed)                           \
-    FN(strided_slice_float_11)                                   \
-    FN(strided_slice_float_11_relaxed)                           \
-    FN(strided_slice_float_1_relaxed)                            \
-    FN(strided_slice_float_2)                                    \
-    FN(strided_slice_float_2_relaxed)                            \
-    FN(strided_slice_float_3)                                    \
-    FN(strided_slice_float_3_relaxed)                            \
-    FN(strided_slice_float_4)                                    \
-    FN(strided_slice_float_4_relaxed)                            \
-    FN(strided_slice_float_5)                                    \
-    FN(strided_slice_float_5_relaxed)                            \
-    FN(strided_slice_float_6)                                    \
-    FN(strided_slice_float_6_relaxed)                            \
-    FN(strided_slice_float_7)                                    \
-    FN(strided_slice_float_7_relaxed)                            \
-    FN(strided_slice_float_8)                                    \
-    FN(strided_slice_float_8_relaxed)                            \
-    FN(strided_slice_float_9)                                    \
-    FN(strided_slice_float_9_relaxed)                            \
-    FN(strided_slice_qaunt8_10)                                  \
-    FN(strided_slice_qaunt8_11)                                  \
-    FN(strided_slice_quant8_1)                                   \
-    FN(strided_slice_quant8_2)                                   \
-    FN(strided_slice_quant8_3)                                   \
-    FN(strided_slice_quant8_4)                                   \
-    FN(strided_slice_quant8_5)                                   \
-    FN(strided_slice_quant8_6)                                   \
-    FN(strided_slice_quant8_7)                                   \
-    FN(strided_slice_quant8_8)                                   \
-    FN(strided_slice_quant8_9)                                   \
-    FN(strided_slice_relaxed)                                    \
-    FN(sub)                                                      \
-    FN(sub_broadcast_float)                                      \
-    FN(sub_broadcast_float_relaxed)                              \
-    FN(sub_relaxed)                                              \
-    FN(svdf)                                                     \
-    FN(svdf2)                                                    \
-    FN(svdf2_relaxed)                                            \
-    FN(svdf_relaxed)                                             \
-    FN(svdf_state)                                               \
-    FN(svdf_state_relaxed)                                       \
-    FN(tanh)                                                     \
-    FN(tanh_relaxed)                                             \
-    FN(transpose)                                                \
-    FN(transpose_float_1)                                        \
-    FN(transpose_float_1_relaxed)                                \
-    FN(transpose_quant8_1)                                       \
-    FN(transpose_relaxed)
-
-#define FORWARD_DECLARE_GENERATED_OBJECTS(function) \
-    namespace function {                            \
-    extern std::vector<MixedTypedExample> examples; \
-    Model createTestModel();                        \
-    }
-
-FOR_EACH_TEST_MODEL(FORWARD_DECLARE_GENERATED_OBJECTS)
-
-#undef FORWARD_DECLARE_GENERATED_OBJECTS
-
-}  // namespace functional
-}  // namespace vts
-}  // namespace V1_2
-}  // namespace neuralnetworks
-}  // namespace hardware
-}  // namespace android
-
-#endif  // VTS_HAL_NEURALNETWORKS_V1_2_VTS_FUNCTIONAL_MODELS_H
diff --git a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp
index c1c6e55..562ac33 100644
--- a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp
+++ b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp
@@ -128,16 +128,16 @@
 
 ///////////////////////// VALIDATE MODEL OPERAND TYPE /////////////////////////
 
-static const int32_t invalidOperandTypes[] = {
-    static_cast<int32_t>(OperandType::FLOAT32) - 1,               // lower bound fundamental
-    static_cast<int32_t>(OperandType::TENSOR_QUANT16_ASYMM) + 1,  // upper bound fundamental
-    static_cast<int32_t>(OperandType::OEM) - 1,                   // lower bound OEM
-    static_cast<int32_t>(OperandType::TENSOR_OEM_BYTE) + 1,       // upper bound OEM
+static const uint32_t invalidOperandTypes[] = {
+    static_cast<uint32_t>(OperandTypeRange::OPERAND_FUNDAMENTAL_MIN) - 1,
+    static_cast<uint32_t>(OperandTypeRange::OPERAND_FUNDAMENTAL_MAX) + 1,
+    static_cast<uint32_t>(OperandTypeRange::OPERAND_OEM_MIN) - 1,
+    static_cast<uint32_t>(OperandTypeRange::OPERAND_OEM_MAX) + 1,
 };
 
 static void mutateOperandTypeTest(const sp<IDevice>& device, const Model& model) {
     for (size_t operand = 0; operand < model.operands.size(); ++operand) {
-        for (int32_t invalidOperandType : invalidOperandTypes) {
+        for (uint32_t invalidOperandType : invalidOperandTypes) {
             const std::string message = "mutateOperandTypeTest: operand " +
                                         std::to_string(operand) + " set to value " +
                                         std::to_string(invalidOperandType);
@@ -161,7 +161,7 @@
         case OperandType::TENSOR_FLOAT32:
         case OperandType::TENSOR_INT32:
         case OperandType::TENSOR_QUANT8_ASYMM:
-        case OperandType::TENSOR_QUANT16_ASYMM:
+        case OperandType::TENSOR_QUANT16_SYMM:
             return 0;
         default:
             return 0;
@@ -193,7 +193,7 @@
         case OperandType::TENSOR_INT32:
             return -1.0f;
         case OperandType::TENSOR_QUANT8_ASYMM:
-        case OperandType::TENSOR_QUANT16_ASYMM:
+        case OperandType::TENSOR_QUANT16_SYMM:
             return 0.0f;
         default:
             return 0.0f;
@@ -224,8 +224,9 @@
         case OperandType::TENSOR_INT32:
             return {1};
         case OperandType::TENSOR_QUANT8_ASYMM:
-        case OperandType::TENSOR_QUANT16_ASYMM:
             return {-1, 256};
+        case OperandType::TENSOR_QUANT16_SYMM:
+            return {-32769, -1, 1, 32768};
         default:
             return {};
     }
@@ -278,7 +279,7 @@
             newOperand.zeroPoint = 0;
             break;
         case OperandType::TENSOR_QUANT8_ASYMM:
-        case OperandType::TENSOR_QUANT16_ASYMM:
+        case OperandType::TENSOR_QUANT16_SYMM:
             newOperand.dimensions =
                 operand->dimensions.size() > 0 ? operand->dimensions : hidl_vec<uint32_t>({1});
             newOperand.scale = operand->scale != 0.0f ? operand->scale : 1.0f;
@@ -291,15 +292,40 @@
     *operand = newOperand;
 }
 
-static bool mutateOperationOperandTypeSkip(size_t operand, const Model& model) {
-    // LSH_PROJECTION's second argument is allowed to have any type. This is the
-    // only operation that currently has a type that can be anything independent
-    // from any other type. Changing the operand type to any other type will
-    // result in a valid model for LSH_PROJECTION. If this is the case, skip the
-    // test.
+static bool mutateOperationOperandTypeSkip(size_t operand, OperandType type, const Model& model) {
+    // Do not test OEM types
+    if (type == model.operands[operand].type || type == OperandType::OEM ||
+        type == OperandType::TENSOR_OEM_BYTE) {
+        return true;
+    }
     for (const Operation& operation : model.operations) {
-        if (operation.type == OperationType::LSH_PROJECTION && operand == operation.inputs[1]) {
-            return true;
+        // Skip mutateOperationOperandTypeTest for the following operations.
+        // - LSH_PROJECTION's second argument is allowed to have any type.
+        // - ARGMIN and ARGMAX's first argument can be any of
+        // TENSOR_(FLOAT16|FLOAT32|INT32|QUANT8_ASYMM).
+        // - CAST's argument can be any of TENSOR_(FLOAT16|FLOAT32|INT32|QUANT8_ASYMM).
+        // - RANDOM_MULTINOMIAL's argument can be either TENSOR_FLOAT16 or TENSOR_FLOAT32.
+        switch (operation.type) {
+            case OperationType::LSH_PROJECTION: {
+                if (operand == operation.inputs[1]) {
+                    return true;
+                }
+            } break;
+            case OperationType::CAST:
+            case OperationType::ARGMAX:
+            case OperationType::ARGMIN: {
+                if (type == OperandType::TENSOR_FLOAT16 || type == OperandType::TENSOR_FLOAT32 ||
+                    type == OperandType::TENSOR_INT32 || type == OperandType::TENSOR_QUANT8_ASYMM) {
+                    return true;
+                }
+            } break;
+            case OperationType::RANDOM_MULTINOMIAL: {
+                if (type == OperandType::TENSOR_FLOAT16 || type == OperandType::TENSOR_FLOAT32) {
+                    return true;
+                }
+            } break;
+            default:
+                break;
         }
     }
     return false;
@@ -307,14 +333,8 @@
 
 static void mutateOperationOperandTypeTest(const sp<IDevice>& device, const Model& model) {
     for (size_t operand = 0; operand < model.operands.size(); ++operand) {
-        if (mutateOperationOperandTypeSkip(operand, model)) {
-            continue;
-        }
         for (OperandType invalidOperandType : hidl_enum_range<OperandType>{}) {
-            // Do not test OEM types
-            if (invalidOperandType == model.operands[operand].type ||
-                invalidOperandType == OperandType::OEM ||
-                invalidOperandType == OperandType::TENSOR_OEM_BYTE) {
+            if (mutateOperationOperandTypeSkip(operand, invalidOperandType, model)) {
                 continue;
             }
             const std::string message = "mutateOperationOperandTypeTest: operand " +
@@ -329,16 +349,16 @@
 
 ///////////////////////// VALIDATE MODEL OPERATION TYPE /////////////////////////
 
-static const int32_t invalidOperationTypes[] = {
-    static_cast<int32_t>(OperationType::ADD) - 1,            // lower bound fundamental
-    static_cast<int32_t>(OperationType::TRANSPOSE) + 1,      // upper bound fundamental
-    static_cast<int32_t>(OperationType::OEM_OPERATION) - 1,  // lower bound OEM
-    static_cast<int32_t>(OperationType::OEM_OPERATION) + 1,  // upper bound OEM
+static const uint32_t invalidOperationTypes[] = {
+    static_cast<uint32_t>(OperationTypeRange::OPERATION_FUNDAMENTAL_MIN) - 1,
+    static_cast<uint32_t>(OperationTypeRange::OPERATION_FUNDAMENTAL_MAX) + 1,
+    static_cast<uint32_t>(OperationTypeRange::OPERATION_OEM_MIN) - 1,
+    static_cast<uint32_t>(OperationTypeRange::OPERATION_OEM_MAX) + 1,
 };
 
 static void mutateOperationTypeTest(const sp<IDevice>& device, const Model& model) {
     for (size_t operation = 0; operation < model.operations.size(); ++operation) {
-        for (int32_t invalidOperationType : invalidOperationTypes) {
+        for (uint32_t invalidOperationType : invalidOperationTypes) {
             const std::string message = "mutateOperationTypeTest: operation " +
                                         std::to_string(operation) + " set to value " +
                                         std::to_string(invalidOperationType);
@@ -406,8 +426,26 @@
     removeValueAndDecrementGreaterValues(&model->outputIndexes, index);
 }
 
+static bool removeOperandSkip(size_t operand, const Model& model) {
+    for (const Operation& operation : model.operations) {
+        // Skip removeOperandTest for the following operations.
+        // - SPLIT's outputs are not checked during prepareModel.
+        if (operation.type == OperationType::SPLIT) {
+            for (const size_t outOprand : operation.outputs) {
+                if (operand == outOprand) {
+                    return true;
+                }
+            }
+        }
+    }
+    return false;
+}
+
 static void removeOperandTest(const sp<IDevice>& device, const Model& model) {
     for (size_t operand = 0; operand < model.operands.size(); ++operand) {
+        if (removeOperandSkip(operand, model)) {
+            continue;
+        }
         const std::string message = "removeOperandTest: operand " + std::to_string(operand);
         validate(device, message, model,
                  [operand](Model* model) { removeOperand(model, operand); });
@@ -433,15 +471,76 @@
 
 ///////////////////////// REMOVE OPERATION INPUT /////////////////////////
 
+static bool removeOperationInputSkip(const Operation& op, size_t input) {
+    // Skip removeOperationInputTest for the following operations.
+    // - CONCATENATION has at least 2 inputs, with the last element being INT32.
+    // - CONV_2D, DEPTHWISE_CONV_2D, MAX_POOL_2D, AVERAGE_POOL_2D, L2_POOL_2D, RESIZE_BILINEAR,
+    //   SPACE_TO_DEPTH, SPACE_TO_DEPTH, SPACE_TO_BATCH_ND, BATCH_TO_SPACE_ND can have an optional
+    //   layout parameter.
+    // - L2_NORMALIZATION, LOCAL_RESPONSE_NORMALIZATION, SOFTMAX can have an optional axis
+    //   parameter.
+    switch (op.type) {
+        case OperationType::CONCATENATION: {
+            if (op.inputs.size() > 2 && input != op.inputs.size() - 1) {
+                return true;
+            }
+        } break;
+        case OperationType::DEPTHWISE_CONV_2D: {
+            if ((op.inputs.size() == 12 && input == 11) || (op.inputs.size() == 9 && input == 8)) {
+                return true;
+            }
+        } break;
+        case OperationType::CONV_2D:
+        case OperationType::AVERAGE_POOL_2D:
+        case OperationType::MAX_POOL_2D:
+        case OperationType::L2_POOL_2D: {
+            if ((op.inputs.size() == 11 && input == 10) || (op.inputs.size() == 8 && input == 7)) {
+                return true;
+            }
+        } break;
+        case OperationType::RESIZE_BILINEAR: {
+            if (op.inputs.size() == 4 && input == 3) {
+                return true;
+            }
+        } break;
+        case OperationType::SPACE_TO_DEPTH:
+        case OperationType::DEPTH_TO_SPACE:
+        case OperationType::BATCH_TO_SPACE_ND: {
+            if (op.inputs.size() == 3 && input == 2) {
+                return true;
+            }
+        } break;
+        case OperationType::SPACE_TO_BATCH_ND: {
+            if (op.inputs.size() == 4 && input == 3) {
+                return true;
+            }
+        } break;
+        case OperationType::L2_NORMALIZATION: {
+            if (op.inputs.size() == 2 && input == 1) {
+                return true;
+            }
+        } break;
+        case OperationType::LOCAL_RESPONSE_NORMALIZATION: {
+            if (op.inputs.size() == 6 && input == 5) {
+                return true;
+            }
+        } break;
+        case OperationType::SOFTMAX: {
+            if (op.inputs.size() == 3 && input == 2) {
+                return true;
+            }
+        } break;
+        default:
+            break;
+    }
+    return false;
+}
+
 static void removeOperationInputTest(const sp<IDevice>& device, const Model& model) {
     for (size_t operation = 0; operation < model.operations.size(); ++operation) {
         for (size_t input = 0; input < model.operations[operation].inputs.size(); ++input) {
             const Operation& op = model.operations[operation];
-            // CONCATENATION has at least 2 inputs, with the last element being
-            // INT32. Skip this test if removing one of CONCATENATION's
-            // inputs still produces a valid model.
-            if (op.type == OperationType::CONCATENATION && op.inputs.size() > 2 &&
-                input != op.inputs.size() - 1) {
+            if (removeOperationInputSkip(op, input)) {
                 continue;
             }
             const std::string message = "removeOperationInputTest: operation " +
@@ -479,12 +578,13 @@
 
 ///////////////////////// ADD OPERATION INPUT /////////////////////////
 
-static bool addOperationInputSkip(const Operation& operation) {
+static bool addOperationInputSkip(const Operation& op) {
     // Skip addOperationInputTest for the following operations.
-    // L2_NORMALIZATION, LOCAL_RESPONSE_NORMALIZATION, SOFTMAX can have an optional axis parameter.
-    if (operation.type == OperationType::L2_NORMALIZATION ||
-        operation.type == OperationType::LOCAL_RESPONSE_NORMALIZATION ||
-        operation.type == OperationType::SOFTMAX) {
+    // - L2_NORMALIZATION, LOCAL_RESPONSE_NORMALIZATION, SOFTMAX can have an optional INT32 axis
+    //   parameter.
+    if ((op.type == OperationType::L2_NORMALIZATION && op.inputs.size() == 1) ||
+        (op.type == OperationType::LOCAL_RESPONSE_NORMALIZATION && op.inputs.size() == 5) ||
+        (op.type == OperationType::SOFTMAX && op.inputs.size() == 2)) {
         return true;
     }
     return false;
diff --git a/neuralnetworks/1.2/vts/functional/ValidationTests.cpp b/neuralnetworks/1.2/vts/functional/ValidationTests.cpp
deleted file mode 100644
index 3bdc5cd..0000000
--- a/neuralnetworks/1.2/vts/functional/ValidationTests.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2018 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 "neuralnetworks_hidl_hal_test"
-
-#include "Models.h"
-#include "VtsHalNeuralnetworks.h"
-
-namespace android {
-namespace hardware {
-namespace neuralnetworks {
-namespace V1_2 {
-namespace vts {
-namespace functional {
-
-// forward declarations
-std::vector<Request> createRequests(const std::vector<MixedTypedExample>& examples);
-
-// generate validation tests
-#define VTS_CURRENT_TEST_CASE(TestName)                                           \
-    TEST_F(ValidationTest, TestName) {                                            \
-        const Model model = TestName::createTestModel();                          \
-        const std::vector<Request> requests = createRequests(TestName::examples); \
-        validateModel(model);                                                     \
-        validateRequests(model, requests);                                        \
-    }
-
-FOR_EACH_TEST_MODEL(VTS_CURRENT_TEST_CASE)
-
-#undef VTS_CURRENT_TEST_CASE
-
-}  // namespace functional
-}  // namespace vts
-}  // namespace V1_2
-}  // namespace neuralnetworks
-}  // namespace hardware
-}  // namespace android
diff --git a/nfc/1.0/vts/functional/Android.bp b/nfc/1.0/vts/functional/Android.bp
index 3861bd4..c2e365e 100644
--- a/nfc/1.0/vts/functional/Android.bp
+++ b/nfc/1.0/vts/functional/Android.bp
@@ -21,4 +21,5 @@
     static_libs: [
         "android.hardware.nfc@1.0",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/nfc/1.1/vts/functional/Android.bp b/nfc/1.1/vts/functional/Android.bp
index 0ce531f..6698c5a 100644
--- a/nfc/1.1/vts/functional/Android.bp
+++ b/nfc/1.1/vts/functional/Android.bp
@@ -22,4 +22,5 @@
         "android.hardware.nfc@1.0",
         "android.hardware.nfc@1.1",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/oemlock/1.0/vts/functional/Android.bp b/oemlock/1.0/vts/functional/Android.bp
index 20737a1..28d6bf6 100644
--- a/oemlock/1.0/vts/functional/Android.bp
+++ b/oemlock/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalOemLockV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.oemlock@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/power/1.0/vts/functional/Android.bp b/power/1.0/vts/functional/Android.bp
index 45f74fc..a716f02 100644
--- a/power/1.0/vts/functional/Android.bp
+++ b/power/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalPowerV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.power@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/power/1.1/vts/functional/Android.bp b/power/1.1/vts/functional/Android.bp
index 604cd36..de75984 100644
--- a/power/1.1/vts/functional/Android.bp
+++ b/power/1.1/vts/functional/Android.bp
@@ -22,4 +22,5 @@
         "android.hardware.power@1.0",
         "android.hardware.power@1.1",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/power/1.2/vts/functional/Android.bp b/power/1.2/vts/functional/Android.bp
index d615e85..f424bfa 100644
--- a/power/1.2/vts/functional/Android.bp
+++ b/power/1.2/vts/functional/Android.bp
@@ -23,4 +23,5 @@
         "android.hardware.power@1.1",
         "android.hardware.power@1.2",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/power/1.3/vts/functional/Android.bp b/power/1.3/vts/functional/Android.bp
index 34cdb60..06f6e7a 100644
--- a/power/1.3/vts/functional/Android.bp
+++ b/power/1.3/vts/functional/Android.bp
@@ -24,4 +24,5 @@
         "android.hardware.power@1.2",
         "android.hardware.power@1.3",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/power/stats/1.0/IPowerStats.hal b/power/stats/1.0/IPowerStats.hal
index 75c6a72..74ceb8f 100644
--- a/power/stats/1.0/IPowerStats.hal
+++ b/power/stats/1.0/IPowerStats.hal
@@ -105,9 +105,9 @@
      * consumption.
      *
      * @return powerEntityInfos List of information on each PowerEntity
-     * @return status SUCCESS on success or NOT_SUPPORTED if
-     *     feature is not enabled or FILESYSTEM_ERROR on filesystem nodes
-     *     access error.
+     * @return status SUCCESS on success, NOT_SUPPORTED if feature is not
+     *     enabled, FILESYSTEM_ERROR if there was an error accessing the
+     *     filesystem.
      */
     getPowerEntityInfo()
         generates(vec<PowerEntityInfo> powerEntityInfos, Status status);
@@ -123,12 +123,11 @@
      *     information for all PowerEntity(s) pass an empty vector.
      *
      * @return powerEntityStateSpaces PowerEntity state space information for
-     *     each specified PowerEntity.
-     * @return status SUCCESS if powerEntityStateInfos contains state space
-     *     information for at least one PowerEntity, NOT_SUPPORTED if feature
-     *     is not enabled, INVALID_INPUT if no requested PowerEntity(s)
-     *     provide state space information, FILESYSTEM_ERROR if no state space
-     *     information is returned due to filesystem errors.
+     *     each specified PowerEntity that provides state space information.
+     * @return status SUCCESS on success, NOT_SUPPORTED if feature is not
+     *     enabled, FILESYSTEM_ERROR if there was an error accessing the
+     *     filesystem, INVALID_INPUT if any requested PowerEntity(s) do not
+     *     provide state space information and there was not a filesystem error.
      */
     getPowerEntityStateInfo(vec<uint32_t> powerEntityIds)
         generates(vec<PowerEntityStateSpace> powerEntityStateSpaces,
@@ -148,13 +147,12 @@
      *     residency data is requested. PowerEntity name to ID mapping may
      *     be queried from getPowerEntityInfo(). To get state residency
      *     data for all PowerEntity(s) pass an empty vector.
-     * @return stateResidencyResults state residency data for the
-     *     specified powerEntity(s)
-     * @return status SUCCESS if stateResidencyResults contains residency
-     *     data for at least one PowerEntity, NOT_SUPPORTED if
-     *     feature is not enabled, INVALID_INPUT if no requested
-     *     PowerEntity(s) provide state residency data, FILESYSTEM_ERROR
-     *     if no data is returned due to filesystem errors.
+     * @return stateResidencyResults state residency data for each specified
+     *     PowerEntity that provides state residency data.
+     * @return status SUCCESS on success, NOT_SUPPORTED if feature is not
+     *     enabled, FILESYSTEM_ERROR if there was an error accessing the
+     *     filesystem, INVALID_INPUT if any requested PowerEntity(s) do not
+     *     provide state residency data and there was not a filesystem error.
      */
     getPowerEntityStateResidencyData(vec<uint32_t> powerEntityIds)
         generates(vec<PowerEntityStateResidencyResult> stateResidencyResults,
diff --git a/power/stats/1.0/default/Android.bp b/power/stats/1.0/default/Android.bp
new file mode 100644
index 0000000..04270c1
--- /dev/null
+++ b/power/stats/1.0/default/Android.bp
@@ -0,0 +1,34 @@
+// Copyright (C) 2018 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
+
+cc_library_shared {
+    name: "android.hardware.power.stats@1.0-service",
+    relative_install_path: "hw",
+    init_rc: ["android.hardware.power.stats@1.0-service.rc"],
+    srcs: ["service.cpp", "PowerStats.cpp"],
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+    shared_libs: [
+        "libbase",
+        "libcutils",
+        "libfmq",
+        "libhidlbase",
+        "libhidltransport",
+        "liblog",
+        "libutils",
+        "android.hardware.power.stats@1.0",
+    ],
+    vendor: true,
+}
diff --git a/power/stats/1.0/default/PowerStats.cpp b/power/stats/1.0/default/PowerStats.cpp
new file mode 100644
index 0000000..810c575
--- /dev/null
+++ b/power/stats/1.0/default/PowerStats.cpp
@@ -0,0 +1,317 @@
+/*
+ * Copyright (C) 2018 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 "PowerStats.h"
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <android-base/properties.h>
+#include <android-base/stringprintf.h>
+#include <android-base/strings.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <algorithm>
+#include <exception>
+#include <thread>
+
+namespace android {
+namespace hardware {
+namespace power {
+namespace stats {
+namespace V1_0 {
+namespace implementation {
+
+#define MAX_FILE_PATH_LEN 128
+#define MAX_DEVICE_NAME_LEN 64
+#define MAX_QUEUE_SIZE 8192
+
+constexpr char kIioDirRoot[] = "/sys/bus/iio/devices/";
+constexpr char kDeviceName[] = "pm_device_name";
+constexpr char kDeviceType[] = "iio:device";
+constexpr uint32_t MAX_SAMPLING_RATE = 10;
+constexpr uint64_t WRITE_TIMEOUT_NS = 1000000000;
+
+void PowerStats::findIioPowerMonitorNodes() {
+    struct dirent* ent;
+    int fd;
+    char devName[MAX_DEVICE_NAME_LEN];
+    char filePath[MAX_FILE_PATH_LEN];
+    DIR* iioDir = opendir(kIioDirRoot);
+    if (!iioDir) {
+        ALOGE("Error opening directory: %s", kIioDirRoot);
+        return;
+    }
+    while (ent = readdir(iioDir), ent) {
+        if (strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0 &&
+            strlen(ent->d_name) > strlen(kDeviceType) &&
+            strncmp(ent->d_name, kDeviceType, strlen(kDeviceType)) == 0) {
+            snprintf(filePath, MAX_FILE_PATH_LEN, "%s/%s", ent->d_name, "name");
+            fd = openat(dirfd(iioDir), filePath, O_RDONLY);
+            if (fd < 0) {
+                ALOGW("Failed to open directory: %s", filePath);
+                continue;
+            }
+            if (read(fd, devName, MAX_DEVICE_NAME_LEN) < 0) {
+                ALOGW("Failed to read device name from file: %s(%d)", filePath, fd);
+                close(fd);
+                continue;
+            }
+
+            if (strncmp(devName, kDeviceName, strlen(kDeviceName)) == 0) {
+                snprintf(filePath, MAX_FILE_PATH_LEN, "%s/%s", kIioDirRoot, ent->d_name);
+                mPm.devicePaths.push_back(filePath);
+            }
+            close(fd);
+        }
+    }
+    closedir(iioDir);
+    return;
+}
+
+size_t PowerStats::parsePowerRails() {
+    std::string data;
+    std::string railFileName;
+    std::string spsFileName;
+    uint32_t index = 0;
+    uint32_t samplingRate;
+    for (const auto& path : mPm.devicePaths) {
+        railFileName = path + "/enabled_rails";
+        spsFileName = path + "/sampling_rate";
+        if (!android::base::ReadFileToString(spsFileName, &data)) {
+            ALOGW("Error reading file: %s", spsFileName.c_str());
+            continue;
+        }
+        samplingRate = strtoul(data.c_str(), NULL, 10);
+        if (!samplingRate || samplingRate == ULONG_MAX) {
+            ALOGE("Error parsing: %s", spsFileName.c_str());
+            break;
+        }
+        if (!android::base::ReadFileToString(railFileName, &data)) {
+            ALOGW("Error reading file: %s", railFileName.c_str());
+            continue;
+        }
+        std::istringstream railNames(data);
+        std::string line;
+        while (std::getline(railNames, line)) {
+            std::vector<std::string> words = android::base::Split(line, ":");
+            if (words.size() == 2) {
+                mPm.railsInfo.emplace(words[0], RailData{.devicePath = path,
+                                                         .index = index,
+                                                         .subsysName = words[1],
+                                                         .samplingRate = samplingRate});
+                index++;
+            } else {
+                ALOGW("Unexpected format in file: %s", railFileName.c_str());
+            }
+        }
+    }
+    return index;
+}
+
+int PowerStats::parseIioEnergyNode(std::string devName) {
+    int ret = 0;
+    std::string data;
+    std::string fileName = devName + "/energy_value";
+    if (!android::base::ReadFileToString(fileName, &data)) {
+        ALOGE("Error reading file: %s", fileName.c_str());
+        return -1;
+    }
+
+    std::istringstream energyData(data);
+    std::string line;
+    uint64_t timestamp = 0;
+    bool timestampRead = false;
+    while (std::getline(energyData, line)) {
+        std::vector<std::string> words = android::base::Split(line, ",");
+        if (timestampRead == false) {
+            if (words.size() == 1) {
+                timestamp = strtoull(words[0].c_str(), NULL, 10);
+                if (timestamp == 0 || timestamp == ULLONG_MAX) {
+                    ALOGW("Potentially wrong timestamp: %" PRIu64, timestamp);
+                }
+                timestampRead = true;
+            }
+        } else if (words.size() == 2) {
+            std::string railName = words[0];
+            if (mPm.railsInfo.count(railName) != 0) {
+                size_t index = mPm.railsInfo[railName].index;
+                mPm.reading[index].index = index;
+                mPm.reading[index].timestamp = timestamp;
+                mPm.reading[index].energy = strtoull(words[1].c_str(), NULL, 10);
+                if (mPm.reading[index].energy == ULLONG_MAX) {
+                    ALOGW("Potentially wrong energy value: %" PRIu64, mPm.reading[index].energy);
+                }
+            }
+        } else {
+            ALOGW("Unexpected format in file: %s", fileName.c_str());
+            ret = -1;
+            break;
+        }
+    }
+    return ret;
+}
+
+Status PowerStats::parseIioEnergyNodes() {
+    Status ret = Status::SUCCESS;
+    if (mPm.hwEnabled == false) {
+        return Status::NOT_SUPPORTED;
+    }
+
+    for (const auto& devicePath : mPm.devicePaths) {
+        if (parseIioEnergyNode(devicePath) < 0) {
+            ALOGE("Error in parsing power stats");
+            ret = Status::FILESYSTEM_ERROR;
+            break;
+        }
+    }
+    return ret;
+}
+
+PowerStats::PowerStats() {
+    findIioPowerMonitorNodes();
+    size_t numRails = parsePowerRails();
+    if (mPm.devicePaths.empty() || numRails == 0) {
+        mPm.hwEnabled = false;
+    } else {
+        mPm.hwEnabled = true;
+        mPm.reading.resize(numRails);
+    }
+}
+
+Return<void> PowerStats::getRailInfo(getRailInfo_cb _hidl_cb) {
+    hidl_vec<RailInfo> rInfo;
+    Status ret = Status::SUCCESS;
+    size_t index;
+    std::lock_guard<std::mutex> _lock(mPm.mLock);
+    if (mPm.hwEnabled == false) {
+        _hidl_cb(rInfo, Status::NOT_SUPPORTED);
+        return Void();
+    }
+    rInfo.resize(mPm.railsInfo.size());
+    for (const auto& railData : mPm.railsInfo) {
+        index = railData.second.index;
+        rInfo[index].railName = railData.first;
+        rInfo[index].subsysName = railData.second.subsysName;
+        rInfo[index].index = index;
+        rInfo[index].samplingRate = railData.second.samplingRate;
+    }
+    _hidl_cb(rInfo, ret);
+    return Void();
+}
+
+Return<void> PowerStats::getEnergyData(const hidl_vec<uint32_t>& railIndices,
+                                       getEnergyData_cb _hidl_cb) {
+    hidl_vec<EnergyData> eVal;
+    std::lock_guard<std::mutex> _lock(mPm.mLock);
+    Status ret = parseIioEnergyNodes();
+
+    if (ret != Status::SUCCESS) {
+        ALOGE("Failed to getEnergyData");
+        _hidl_cb(eVal, ret);
+        return Void();
+    }
+
+    if (railIndices.size() == 0) {
+        eVal.resize(mPm.railsInfo.size());
+        memcpy(&eVal[0], &mPm.reading[0], mPm.reading.size() * sizeof(EnergyData));
+    } else {
+        eVal.resize(railIndices.size());
+        int i = 0;
+        for (const auto& railIndex : railIndices) {
+            if (railIndex >= mPm.reading.size()) {
+                ret = Status::INVALID_INPUT;
+                eVal.resize(0);
+                break;
+            }
+            memcpy(&eVal[i], &mPm.reading[railIndex], sizeof(EnergyData));
+            i++;
+        }
+    }
+    _hidl_cb(eVal, ret);
+    return Void();
+}
+
+Return<void> PowerStats::streamEnergyData(uint32_t timeMs, uint32_t samplingRate,
+                                          streamEnergyData_cb _hidl_cb) {
+    std::lock_guard<std::mutex> _lock(mPm.mLock);
+    if (mPm.fmqSynchronized != nullptr) {
+        _hidl_cb(MessageQueueSync::Descriptor(), 0, 0, Status::INSUFFICIENT_RESOURCES);
+        return Void();
+    }
+    uint32_t sps = std::min(samplingRate, MAX_SAMPLING_RATE);
+    uint32_t numSamples = timeMs * sps / 1000;
+    mPm.fmqSynchronized.reset(new (std::nothrow) MessageQueueSync(MAX_QUEUE_SIZE, true));
+    if (mPm.fmqSynchronized == nullptr || mPm.fmqSynchronized->isValid() == false) {
+        mPm.fmqSynchronized = nullptr;
+        _hidl_cb(MessageQueueSync::Descriptor(), 0, 0, Status::INSUFFICIENT_RESOURCES);
+        return Void();
+    }
+    std::thread pollThread = std::thread([this, sps, numSamples]() {
+        uint64_t sleepTimeUs = 1000000 / sps;
+        uint32_t currSamples = 0;
+        while (currSamples < numSamples) {
+            mPm.mLock.lock();
+            if (parseIioEnergyNodes() == Status::SUCCESS) {
+                mPm.fmqSynchronized->writeBlocking(&mPm.reading[0], mPm.reading.size(),
+                                                   WRITE_TIMEOUT_NS);
+                mPm.mLock.unlock();
+                currSamples++;
+                if (usleep(sleepTimeUs) < 0) {
+                    ALOGW("Sleep interrupted");
+                    break;
+                }
+            } else {
+                mPm.mLock.unlock();
+                break;
+            }
+        }
+        mPm.mLock.lock();
+        mPm.fmqSynchronized = nullptr;
+        mPm.mLock.unlock();
+        return;
+    });
+    pollThread.detach();
+    _hidl_cb(*(mPm.fmqSynchronized)->getDesc(), numSamples, mPm.reading.size(), Status::SUCCESS);
+    return Void();
+}
+
+Return<void> PowerStats::getPowerEntityInfo(getPowerEntityInfo_cb _hidl_cb) {
+    hidl_vec<PowerEntityInfo> eInfo;
+    _hidl_cb(eInfo, Status::NOT_SUPPORTED);
+    return Void();
+}
+
+Return<void> PowerStats::getPowerEntityStateInfo(const hidl_vec<uint32_t>& powerEntityIds,
+                                                 getPowerEntityStateInfo_cb _hidl_cb) {
+    (void)powerEntityIds;
+    hidl_vec<PowerEntityStateSpace> powerEntityStateSpaces;
+    _hidl_cb(powerEntityStateSpaces, Status::NOT_SUPPORTED);
+    return Void();
+}
+
+Return<void> PowerStats::getPowerEntityStateResidencyData(
+    const hidl_vec<uint32_t>& powerEntityIds, getPowerEntityStateResidencyData_cb _hidl_cb) {
+    (void)powerEntityIds;
+    hidl_vec<PowerEntityStateResidencyResult> results;
+    _hidl_cb(results, Status::NOT_SUPPORTED);
+    return Void();
+}
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace stats
+}  // namespace power
+}  // namespace hardware
+}  // namespace android
diff --git a/power/stats/1.0/default/PowerStats.h b/power/stats/1.0/default/PowerStats.h
new file mode 100644
index 0000000..fb2c6a8
--- /dev/null
+++ b/power/stats/1.0/default/PowerStats.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HARDWARE_POWERSTATS_V1_0_POWERSTATS_H
+#define ANDROID_HARDWARE_POWERSTATS_V1_0_POWERSTATS_H
+
+#include <android/hardware/power/stats/1.0/IPowerStats.h>
+#include <fmq/MessageQueue.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace power {
+namespace stats {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::hidl_vec;
+using ::android::hardware::kSynchronizedReadWrite;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::power::stats::V1_0::EnergyData;
+using ::android::hardware::power::stats::V1_0::PowerEntityInfo;
+using ::android::hardware::power::stats::V1_0::PowerEntityStateInfo;
+using ::android::hardware::power::stats::V1_0::PowerEntityStateResidencyData;
+using ::android::hardware::power::stats::V1_0::PowerEntityStateResidencyResult;
+using ::android::hardware::power::stats::V1_0::PowerEntityStateSpace;
+using ::android::hardware::power::stats::V1_0::PowerEntityType;
+using ::android::hardware::power::stats::V1_0::RailInfo;
+using ::android::hardware::power::stats::V1_0::Status;
+
+typedef MessageQueue<EnergyData, kSynchronizedReadWrite> MessageQueueSync;
+struct RailData {
+    std::string devicePath;
+    uint32_t index;
+    std::string subsysName;
+    uint32_t samplingRate;
+};
+
+struct OnDeviceMmt {
+    std::mutex mLock;
+    bool hwEnabled;
+    std::vector<std::string> devicePaths;
+    std::map<std::string, RailData> railsInfo;
+    std::vector<EnergyData> reading;
+    std::unique_ptr<MessageQueueSync> fmqSynchronized;
+};
+
+struct PowerStats : public IPowerStats {
+    PowerStats();
+    // Methods from ::android::hardware::power::stats::V1_0::IPowerStats follow.
+    Return<void> getRailInfo(getRailInfo_cb _hidl_cb) override;
+    Return<void> getEnergyData(const hidl_vec<uint32_t>& railIndices,
+                               getEnergyData_cb _hidl_cb) override;
+    Return<void> streamEnergyData(uint32_t timeMs, uint32_t samplingRate,
+                                  streamEnergyData_cb _hidl_cb) override;
+    Return<void> getPowerEntityInfo(getPowerEntityInfo_cb _hidl_cb) override;
+    Return<void> getPowerEntityStateInfo(const hidl_vec<uint32_t>& powerEntityIds,
+                                         getPowerEntityStateInfo_cb _hidl_cb) override;
+    Return<void> getPowerEntityStateResidencyData(
+        const hidl_vec<uint32_t>& powerEntityIds,
+        getPowerEntityStateResidencyData_cb _hidl_cb) override;
+
+   private:
+    OnDeviceMmt mPm;
+    void findIioPowerMonitorNodes();
+    size_t parsePowerRails();
+    int parseIioEnergyNode(std::string devName);
+    Status parseIioEnergyNodes();
+};
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace stats
+}  // namespace power
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_POWERSTATS_V1_0_POWERSTATS_H
diff --git a/power/stats/1.0/default/android.hardware.power.stats@1.0-service.rc b/power/stats/1.0/default/android.hardware.power.stats@1.0-service.rc
new file mode 100644
index 0000000..d7e546b
--- /dev/null
+++ b/power/stats/1.0/default/android.hardware.power.stats@1.0-service.rc
@@ -0,0 +1,4 @@
+service vendor.power.stats-hal-1-0 /vendor/bin/hw/android.hardware.power.stats@1.0-service
+    class hal
+    user system
+    group system
diff --git a/power/stats/1.0/default/service.cpp b/power/stats/1.0/default/service.cpp
new file mode 100644
index 0000000..80649f5
--- /dev/null
+++ b/power/stats/1.0/default/service.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "android.hardware.power.stats@1.0-service"
+
+#include <android/log.h>
+#include <hidl/HidlTransportSupport.h>
+
+#include "PowerStats.h"
+
+using android::OK;
+using android::sp;
+using android::status_t;
+
+// libhwbinder:
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+
+// Generated HIDL files
+using android::hardware::power::stats::V1_0::IPowerStats;
+using android::hardware::power::stats::V1_0::implementation::PowerStats;
+
+int main(int /* argc */, char** /* argv */) {
+    ALOGI("power.stats service 1.0 is starting.");
+
+    android::sp<IPowerStats> service = new PowerStats();
+    if (service == nullptr) {
+        ALOGE("Can not create an instance of power.stats HAL Iface, exiting.");
+        return 1;
+    }
+
+    configureRpcThreadpool(1, true /*callerWillJoin*/);
+
+    status_t status = service->registerAsService();
+    if (status != OK) {
+        ALOGE("Could not register service for power.stats HAL Iface (%d), exiting.", status);
+        return 1;
+    }
+
+    ALOGI("power.stats service is ready");
+    joinRpcThreadpool();
+
+    // In normal operation, we don't expect the thread pool to exit
+    ALOGE("power.stats service is shutting down");
+    return 1;
+}
diff --git a/power/stats/1.0/types.hal b/power/stats/1.0/types.hal
index 986a6bb..644224b 100644
--- a/power/stats/1.0/types.hal
+++ b/power/stats/1.0/types.hal
@@ -69,19 +69,18 @@
  * given PowerEntity.
  */
 struct PowerEntityInfo {
-    /** ID corresponding to the PowerEntity */
+    /** Unique ID corresponding to the PowerEntity */
     uint32_t powerEntityId;
-    /**
-     * Name of the PowerEntity. This is unique and opaque to the
-     * Android framework
-     */
+    /** Name of the PowerEntity */
     string powerEntityName;
     /** Type of the PowerEntity */
     PowerEntityType type;
 };
 
 struct PowerEntityStateInfo {
-    /** ID corresponding to the state */
+    /**
+     * ID corresponding to the state. Unique for a given PowerEntityStateSpace
+     */
     uint32_t powerEntityStateId;
     /** Name of the state */
     string powerEntityStateName;
@@ -93,7 +92,7 @@
  * PowerEntity provides residency data for.
  */
 struct PowerEntityStateSpace {
-    /** ID of the corresponding PowerEntity */
+    /** Unique ID of the corresponding PowerEntity */
     uint32_t powerEntityId;
 
     /** List of states that the PowerEntity may reside in */
@@ -102,7 +101,7 @@
 
 /** Contains residency data for a single state */
 struct PowerEntityStateResidencyData {
-    /** ID of the corresponding PowerEntityStateInfo */
+    /** Unique ID of the corresponding PowerEntityStateInfo */
     uint32_t powerEntityStateId;
     /**
      * Total time in milliseconds that the corresponding PowerEntity resided
@@ -122,7 +121,7 @@
 };
 
 struct PowerEntityStateResidencyResult {
-    /** ID of the corresponding PowerEntity */
+    /** Unique ID of the corresponding PowerEntity */
     uint32_t powerEntityId;
     /** Residency data for each state the PowerEntity's state space */
     vec<PowerEntityStateResidencyData> stateResidencyData;
diff --git a/audio/common/4.0/default/Android.bp b/power/stats/1.0/vts/functional/Android.bp
similarity index 60%
rename from audio/common/4.0/default/Android.bp
rename to power/stats/1.0/vts/functional/Android.bp
index 57b2e01..4f0b325 100644
--- a/audio/common/4.0/default/Android.bp
+++ b/power/stats/1.0/vts/functional/Android.bp
@@ -12,36 +12,27 @@
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
+//
 
-cc_library_shared {
-    name: "android.hardware.audio.common@4.0-util",
-    defaults: ["hidl_defaults"],
-    vendor_available: true,
-    vndk: {
-        enabled: true,
-    },
+cc_test {
+    name: "VtsHalPowerStatsV1_0TargetTest",
+    defaults: [
+        "VtsHalTargetTestDefaults"
+    ],
     srcs: [
-        "HidlUtils.cpp",
+        "VtsHalPowerStatsV1_0TargetTest.cpp"
     ],
-
-    export_include_dirs: ["."],
-
     static_libs: [
+        "android.hardware.power.stats@1.0"
     ],
-
     shared_libs: [
+        "libbase",
+        "libcutils",
         "liblog",
-        "libutils",
         "libhidlbase",
-        "android.hardware.audio.common-util",
-        "android.hardware.audio.common@4.0",
-    ],
-    export_shared_lib_headers: [
-        "android.hardware.audio.common-util"
-    ],
-
-    header_libs: [
-        "libaudio_system_headers",
-        "libhardware_headers",
+        "libfmq",
+        "libhidltransport",
+        "libhwbinder",
+        "libutils",
     ],
 }
diff --git a/power/stats/1.0/vts/functional/VtsHalPowerStatsV1_0TargetTest.cpp b/power/stats/1.0/vts/functional/VtsHalPowerStatsV1_0TargetTest.cpp
new file mode 100644
index 0000000..9f007e4
--- /dev/null
+++ b/power/stats/1.0/vts/functional/VtsHalPowerStatsV1_0TargetTest.cpp
@@ -0,0 +1,580 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "android.power.stats.vts"
+
+#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
+#include <android-base/logging.h>
+#include <android/hardware/power/stats/1.0/IPowerStats.h>
+#include <fmq/MessageQueue.h>
+#include <hidl/MQDescriptor.h>
+#include <inttypes.h>
+#include <algorithm>
+#include <random>
+#include <thread>
+
+namespace android {
+namespace power {
+namespace stats {
+namespace vts {
+namespace {
+
+using android::sp;
+using android::hardware::hidl_vec;
+using android::hardware::kSynchronizedReadWrite;
+using android::hardware::Return;
+using android::hardware::Void;
+using android::hardware::power::stats::V1_0::EnergyData;
+using android::hardware::power::stats::V1_0::IPowerStats;
+using android::hardware::power::stats::V1_0::PowerEntityInfo;
+using android::hardware::power::stats::V1_0::PowerEntityStateResidencyResult;
+using android::hardware::power::stats::V1_0::PowerEntityStateSpace;
+using android::hardware::power::stats::V1_0::RailInfo;
+using android::hardware::power::stats::V1_0::Status;
+
+}  // namespace
+
+typedef hardware::MessageQueue<EnergyData, kSynchronizedReadWrite> MessageQueueSync;
+// Test environment for Power HIDL HAL.
+class PowerStatsHidlEnv : public ::testing::VtsHalHidlTargetTestEnvBase {
+   public:
+    // get the test environment singleton
+    static PowerStatsHidlEnv* Instance() {
+        static PowerStatsHidlEnv* instance = new PowerStatsHidlEnv;
+        return instance;
+    }
+
+    virtual void registerTestServices() override { registerTestService<IPowerStats>(); }
+};
+
+class PowerStatsHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+   public:
+    virtual void SetUp() override {
+        service_ = ::testing::VtsHalHidlTargetTestBase::getService<IPowerStats>(
+            PowerStatsHidlEnv::Instance()->getServiceName<IPowerStats>());
+        ASSERT_NE(service_, nullptr);
+    }
+
+    virtual void TearDown() override {}
+
+    void getInfos(hidl_vec<PowerEntityInfo>& infos);
+    void getStateSpaces(hidl_vec<PowerEntityStateSpace>& stateSpaces,
+                        const std::vector<uint32_t>& ids);
+    void getResidencyResults(hidl_vec<PowerEntityStateResidencyResult>& results,
+                             const std::vector<uint32_t>& ids);
+    void getRandomIds(std::vector<uint32_t>& ids);
+
+    sp<IPowerStats> service_;
+};
+
+void PowerStatsHidlTest::getInfos(hidl_vec<PowerEntityInfo>& infos) {
+    Status status;
+    Return<void> ret = service_->getPowerEntityInfo([&status, &infos](auto rInfos, auto rStatus) {
+        status = rStatus;
+        infos = rInfos;
+    });
+    ASSERT_TRUE(ret.isOk());
+
+    if (status == Status::SUCCESS) {
+        ASSERT_NE(infos.size(), 0) << "powerEntityInfos must have entries if supported";
+    } else {
+        ASSERT_EQ(status, Status::NOT_SUPPORTED);
+        ASSERT_EQ(infos.size(), 0);
+        LOG(INFO) << "getPowerEntityInfo not supported";
+    }
+}
+
+void PowerStatsHidlTest::getStateSpaces(hidl_vec<PowerEntityStateSpace>& stateSpaces,
+                                        const std::vector<uint32_t>& ids = {}) {
+    Status status;
+    Return<void> ret = service_->getPowerEntityStateInfo(
+        ids, [&status, &stateSpaces](auto rStateSpaces, auto rStatus) {
+            status = rStatus;
+            stateSpaces = rStateSpaces;
+        });
+    ASSERT_TRUE(ret.isOk());
+
+    if (status == Status::SUCCESS) {
+        ASSERT_NE(stateSpaces.size(), 0) << "powerEntityStateSpaces must have entries if supported";
+    } else {
+        ASSERT_EQ(status, Status::NOT_SUPPORTED);
+        ASSERT_EQ(stateSpaces.size(), 0);
+        LOG(INFO) << "getPowerEntityStateInfo not supported";
+    }
+}
+
+void PowerStatsHidlTest::getResidencyResults(hidl_vec<PowerEntityStateResidencyResult>& results,
+                                             const std::vector<uint32_t>& ids = {}) {
+    Status status;
+    Return<void> ret = service_->getPowerEntityStateResidencyData(
+        ids, [&status, &results](auto rResults, auto rStatus) {
+            status = rStatus;
+            results = rResults;
+        });
+    ASSERT_TRUE(ret.isOk());
+
+    if (status == Status::SUCCESS) {
+        ASSERT_NE(results.size(), 0);
+    } else {
+        ASSERT_EQ(status, Status::NOT_SUPPORTED);
+        ASSERT_EQ(results.size(), 0);
+        LOG(INFO) << "getPowerEntityStateResidencyData not supported";
+    }
+}
+
+void PowerStatsHidlTest::getRandomIds(std::vector<uint32_t>& ids) {
+    hidl_vec<PowerEntityStateSpace> stateSpaces;
+    getStateSpaces(stateSpaces);
+
+    if (stateSpaces.size() == 0) {
+        return;
+    }
+
+    for (auto stateSpace : stateSpaces) {
+        ids.push_back(stateSpace.powerEntityId);
+    }
+
+    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+    auto gen = std::default_random_engine(seed);
+    std::uniform_int_distribution<uint32_t> dist(1, stateSpaces.size());
+
+    std::shuffle(ids.begin(), ids.end(), gen);
+    ids.resize(dist(gen));
+}
+
+// Each PowerEntity must have a valid name
+TEST_F(PowerStatsHidlTest, ValidatePowerEntityNames) {
+    hidl_vec<PowerEntityInfo> infos;
+    getInfos(infos);
+    for (auto info : infos) {
+        ASSERT_NE(info.powerEntityName, "");
+    }
+}
+
+// Each PowerEntity must have a unique ID
+TEST_F(PowerStatsHidlTest, ValidatePowerEntityIds) {
+    hidl_vec<PowerEntityInfo> infos;
+    getInfos(infos);
+
+    set<uint32_t> ids;
+    for (auto info : infos) {
+        ASSERT_TRUE(ids.insert(info.powerEntityId).second);
+    }
+}
+
+// Each PowerEntityStateSpace must have an associated PowerEntityInfo
+TEST_F(PowerStatsHidlTest, ValidateStateInfoAssociation) {
+    hidl_vec<PowerEntityInfo> infos;
+    getInfos(infos);
+
+    hidl_vec<PowerEntityStateSpace> stateSpaces;
+    getStateSpaces(stateSpaces);
+
+    std::set<uint32_t> ids;
+    for (auto info : infos) {
+        ids.insert(info.powerEntityId);
+    }
+
+    for (auto stateSpace : stateSpaces) {
+        ASSERT_NE(ids.count(stateSpace.powerEntityId), 0);
+    }
+}
+
+// Each state must have a valid name
+TEST_F(PowerStatsHidlTest, ValidateStateNames) {
+    hidl_vec<PowerEntityStateSpace> stateSpaces;
+    getStateSpaces(stateSpaces);
+
+    for (auto stateSpace : stateSpaces) {
+        for (auto state : stateSpace.states) {
+            ASSERT_NE(state.powerEntityStateName, "");
+        }
+    }
+}
+
+// Each state must have an ID that is unique to the PowerEntityStateSpace
+TEST_F(PowerStatsHidlTest, ValidateStateUniqueIds) {
+    hidl_vec<PowerEntityStateSpace> stateSpaces;
+    getStateSpaces(stateSpaces);
+
+    for (auto stateSpace : stateSpaces) {
+        set<uint32_t> stateIds;
+        for (auto state : stateSpace.states) {
+            ASSERT_TRUE(stateIds.insert(state.powerEntityStateId).second);
+        }
+    }
+}
+
+// getPowerEntityStateInfo must support passing in requested IDs
+// Results must contain state space information for all requested IDs
+TEST_F(PowerStatsHidlTest, ValidateStateInfoAssociationSelect) {
+    std::vector<uint32_t> randomIds;
+    getRandomIds(randomIds);
+
+    if (randomIds.empty()) {
+        return;
+    }
+
+    hidl_vec<PowerEntityStateSpace> stateSpaces;
+    getStateSpaces(stateSpaces, randomIds);
+
+    ASSERT_EQ(stateSpaces.size(), randomIds.size());
+
+    std::set<uint32_t> ids;
+    for (auto id : randomIds) {
+        ids.insert(id);
+    }
+    for (auto stateSpace : stateSpaces) {
+        ASSERT_NE(ids.count(stateSpace.powerEntityId), 0);
+    }
+}
+
+// Requested state space info must match initially obtained stateinfos
+TEST_F(PowerStatsHidlTest, ValidateStateInfoSelect) {
+    hidl_vec<PowerEntityStateSpace> stateSpaces;
+    getStateSpaces(stateSpaces);
+    if (stateSpaces.size() == 0) {
+        return;
+    }
+
+    std::vector<uint32_t> randomIds;
+    getRandomIds(randomIds);
+    ASSERT_FALSE(randomIds.empty());
+
+    hidl_vec<PowerEntityStateSpace> selectedStateSpaces;
+    getStateSpaces(selectedStateSpaces, randomIds);
+
+    std::map<uint32_t, PowerEntityStateSpace> stateSpaceMap;
+    for (auto stateSpace : stateSpaces) {
+        stateSpaceMap[stateSpace.powerEntityId] = stateSpace;
+    }
+
+    for (auto stateSpace : selectedStateSpaces) {
+        auto it = stateSpaceMap.find(stateSpace.powerEntityId);
+        ASSERT_NE(it, stateSpaceMap.end());
+
+        ASSERT_EQ(stateSpace.states.size(), it->second.states.size());
+        for (auto i = 0; i < stateSpace.states.size(); i++) {
+            ASSERT_EQ(stateSpace.states[i].powerEntityStateId,
+                      it->second.states[i].powerEntityStateId);
+            ASSERT_EQ(stateSpace.states[i].powerEntityStateName,
+                      it->second.states[i].powerEntityStateName);
+        }
+    }
+}
+
+// stateResidencyResults must contain results for every PowerEntityStateSpace
+// returned by getPowerEntityStateInfo
+TEST_F(PowerStatsHidlTest, ValidateResidencyResultsAssociation) {
+    hidl_vec<PowerEntityStateSpace> stateSpaces;
+    getStateSpaces(stateSpaces);
+
+    hidl_vec<PowerEntityStateResidencyResult> results;
+    getResidencyResults(results);
+
+    std::map<uint32_t, PowerEntityStateResidencyResult> resultsMap;
+    for (auto result : results) {
+        resultsMap[result.powerEntityId] = result;
+    }
+
+    for (auto stateSpace : stateSpaces) {
+        auto it = resultsMap.find(stateSpace.powerEntityId);
+        ASSERT_NE(it, resultsMap.end());
+
+        ASSERT_EQ(stateSpace.states.size(), it->second.stateResidencyData.size());
+
+        std::set<uint32_t> stateIds;
+        for (auto residency : it->second.stateResidencyData) {
+            stateIds.insert(residency.powerEntityStateId);
+        }
+
+        for (auto state : stateSpace.states) {
+            ASSERT_NE(stateIds.count(state.powerEntityStateId), 0);
+        }
+    }
+}
+
+// getPowerEntityStateResidencyData must support passing in requested IDs
+// stateResidencyResults must contain results for each PowerEntityStateSpace
+// returned by getPowerEntityStateInfo
+TEST_F(PowerStatsHidlTest, ValidateResidencyResultsAssociationSelect) {
+    std::vector<uint32_t> randomIds;
+    getRandomIds(randomIds);
+    if (randomIds.empty()) {
+        return;
+    }
+
+    hidl_vec<PowerEntityStateSpace> stateSpaces;
+    getStateSpaces(stateSpaces, randomIds);
+
+    hidl_vec<PowerEntityStateResidencyResult> results;
+    getResidencyResults(results, randomIds);
+
+    std::map<uint32_t, PowerEntityStateResidencyResult> resultsMap;
+    for (auto result : results) {
+        resultsMap[result.powerEntityId] = result;
+    }
+
+    for (auto stateSpace : stateSpaces) {
+        auto it = resultsMap.find(stateSpace.powerEntityId);
+        ASSERT_NE(it, resultsMap.end());
+
+        ASSERT_EQ(stateSpace.states.size(), it->second.stateResidencyData.size());
+
+        std::set<uint32_t> stateIds;
+        for (auto residency : it->second.stateResidencyData) {
+            stateIds.insert(residency.powerEntityStateId);
+        }
+
+        for (auto state : stateSpace.states) {
+            ASSERT_NE(stateIds.count(state.powerEntityStateId), 0);
+        }
+    }
+}
+
+TEST_F(PowerStatsHidlTest, ValidateRailInfo) {
+    hidl_vec<RailInfo> rails[2];
+    Status s;
+    auto cb = [&rails, &s](hidl_vec<RailInfo> rail_subsys, Status status) {
+        rails[0] = rail_subsys;
+        s = status;
+    };
+    Return<void> ret = service_->getRailInfo(cb);
+    EXPECT_TRUE(ret.isOk());
+    if (s == Status::SUCCESS) {
+        /* Rails size should be non-zero on SUCCESS*/
+        ASSERT_NE(rails[0].size(), 0);
+        /* check if indices returned are unique*/
+        set<uint32_t> ids;
+        for (auto rail : rails[0]) {
+            ASSERT_TRUE(ids.insert(rail.index).second);
+        }
+        auto cb = [&rails, &s](hidl_vec<RailInfo> rail_subsys, Status status) {
+            rails[1] = rail_subsys;
+            s = status;
+        };
+        Return<void> ret = service_->getRailInfo(cb);
+        EXPECT_TRUE(ret.isOk());
+        ASSERT_EQ(s, Status::SUCCESS);
+        ASSERT_EQ(rails[0].size(), rails[1].size());
+        /* check if data returned by two calls to getRailInfo is same*/
+        for (int i = 0; i < rails[0].size(); i++) {
+            ASSERT_NE(rails[0][i].railName, "");
+            ASSERT_NE(rails[0][i].subsysName, "");
+            int j = 0;
+            bool match = false;
+            for (j = 0; j < rails[1].size(); j++) {
+                if (rails[0][i].index == rails[1][j].index) {
+                    ASSERT_EQ(rails[0][i].railName, rails[1][i].railName);
+                    ASSERT_EQ(rails[0][i].subsysName, rails[1][i].subsysName);
+                    match = true;
+                    break;
+                }
+            }
+            ASSERT_TRUE(match);
+        }
+    } else if (s == Status::FILESYSTEM_ERROR) {
+        ALOGI("ValidateRailInfo returned FILESYSTEM_ERROR");
+        ASSERT_EQ(rails[0].size(), 0);
+    } else if (s == Status::NOT_SUPPORTED) {
+        ALOGI("ValidateRailInfo returned NOT_SUPPORTED");
+        ASSERT_EQ(rails[0].size(), 0);
+    } else if (s == Status::INVALID_INPUT) {
+        ALOGI("ValidateRailInfo returned INVALID_INPUT");
+        ASSERT_EQ(rails[0].size(), 0);
+    } else if (s == Status::INSUFFICIENT_RESOURCES) {
+        ALOGI("ValidateRailInfo returned INSUFFICIENT_RESOURCES");
+        ASSERT_EQ(rails[0].size(), 0);
+    }
+}
+
+TEST_F(PowerStatsHidlTest, ValidateAllPowerData) {
+    hidl_vec<EnergyData> measurements[2];
+    Status s;
+    auto cb = [&measurements, &s](hidl_vec<EnergyData> measure, Status status) {
+        measurements[0] = measure;
+        s = status;
+    };
+    Return<void> ret = service_->getEnergyData(hidl_vec<uint32_t>(), cb);
+    EXPECT_TRUE(ret.isOk());
+    if (s == Status::SUCCESS) {
+        /*measurements size should be non-zero on SUCCESS*/
+        ASSERT_NE(measurements[0].size(), 0);
+        auto cb = [&measurements, &s](hidl_vec<EnergyData> measure, Status status) {
+            measurements[1] = measure;
+            s = status;
+        };
+        Return<void> ret = service_->getEnergyData(hidl_vec<uint32_t>(), cb);
+        EXPECT_TRUE(ret.isOk());
+        ASSERT_EQ(s, Status::SUCCESS);
+        /*Both calls should returns same amount of data*/
+        ASSERT_EQ(measurements[0].size(), measurements[1].size());
+        /*Check is energy and timestamp are monotonically increasing*/
+        for (int i = 0; i < measurements[0].size(); i++) {
+            int j;
+            for (j = 0; j < measurements[1].size(); j++) {
+                if (measurements[0][i].index == measurements[1][j].index) {
+                    EXPECT_GE(measurements[1][j].timestamp, measurements[0][i].timestamp);
+                    EXPECT_GE(measurements[1][j].energy, measurements[0][i].energy);
+                    break;
+                }
+            }
+            /*Check is indices for two call match*/
+            ASSERT_NE(j, measurements[1].size());
+        }
+    } else if (s == Status::FILESYSTEM_ERROR) {
+        ALOGI("ValidateAllPowerData returned FILESYSTEM_ERROR");
+        ASSERT_EQ(measurements[0].size(), 0);
+    } else if (s == Status::NOT_SUPPORTED) {
+        ALOGI("ValidateAllPowerData returned NOT_SUPPORTED");
+        ASSERT_EQ(measurements[0].size(), 0);
+    } else if (s == Status::INVALID_INPUT) {
+        ALOGI("ValidateAllPowerData returned INVALID_INPUT");
+        ASSERT_EQ(measurements[0].size(), 0);
+    } else if (s == Status::INSUFFICIENT_RESOURCES) {
+        ALOGI("ValidateAllPowerData returned INSUFFICIENT_RESOURCES");
+        ASSERT_EQ(measurements[0].size(), 0);
+    }
+}
+
+TEST_F(PowerStatsHidlTest, ValidateFilteredPowerData) {
+    hidl_vec<RailInfo> rails;
+    hidl_vec<EnergyData> measurements;
+    hidl_vec<uint32_t> indices;
+    std::string debugString;
+    Status s;
+    auto cb = [&rails, &s](hidl_vec<RailInfo> rail_subsys, Status status) {
+        rails = rail_subsys;
+        s = status;
+    };
+    Return<void> ret = service_->getRailInfo(cb);
+    EXPECT_TRUE(ret.isOk());
+    std::time_t seed = std::time(nullptr);
+    std::srand(seed);
+    if (s == Status::SUCCESS) {
+        size_t sz = std::max(1, (int)(std::rand() % rails.size()));
+        indices.resize(sz);
+        for (int i = 0; i < sz; i++) {
+            int j = std::rand() % rails.size();
+            indices[i] = rails[j].index;
+            debugString += std::to_string(indices[i]) + ", ";
+        }
+        debugString += "\n";
+        ALOGI("ValidateFilteredPowerData for indices: %s", debugString.c_str());
+        auto cb = [&measurements, &s](hidl_vec<EnergyData> measure, Status status) {
+            measurements = measure;
+            s = status;
+        };
+        Return<void> ret = service_->getEnergyData(indices, cb);
+        EXPECT_TRUE(ret.isOk());
+        if (s == Status::SUCCESS) {
+            /* Make sure that all the measurements are returned */
+            ASSERT_EQ(sz, measurements.size());
+            for (int i = 0; i < measurements.size(); i++) {
+                int j;
+                bool match = false;
+                /* Check that the measurement belongs to the requested index */
+                for (j = 0; j < indices.size(); j++) {
+                    if (indices[j] == measurements[i].index) {
+                        match = true;
+                        break;
+                    }
+                }
+                ASSERT_TRUE(match);
+            }
+        }
+    } else {
+        /* size should be zero is stats is NOT SUCCESS */
+        ASSERT_EQ(rails.size(), 0);
+    }
+}
+
+void readEnergy(sp<IPowerStats> service_, uint32_t timeMs) {
+    std::unique_ptr<MessageQueueSync> mQueue;
+    Status s;
+    uint32_t railsInSample;
+    uint32_t totalSamples;
+    auto cb = [&s, &mQueue, &totalSamples, &railsInSample](
+                  const hardware::MQDescriptorSync<EnergyData>& in, uint32_t numSamples,
+                  uint32_t railsPerSample, Status status) {
+        mQueue.reset(new (std::nothrow) MessageQueueSync(in));
+        s = status;
+        totalSamples = numSamples;
+        railsInSample = railsPerSample;
+    };
+    service_->streamEnergyData(timeMs, 10, cb);
+    if (s == Status::SUCCESS) {
+        ASSERT_NE(nullptr, mQueue);
+        ASSERT_TRUE(mQueue->isValid());
+        bool rc;
+        int sampleCount = 0;
+        uint32_t totalQuants = railsInSample * totalSamples;
+        uint64_t timeout_ns = 10000000000;
+        if (totalSamples > 0) {
+            uint32_t batch = std::max(1, (int)((std::rand() % totalSamples) * railsInSample));
+            ALOGI("Read energy, timsMs: %u, batch: %u", timeMs, batch);
+            std::vector<EnergyData> data(batch);
+            while (sampleCount < totalQuants) {
+                rc = mQueue->readBlocking(&data[0], batch, timeout_ns);
+                if (rc == false) {
+                    break;
+                }
+                sampleCount = sampleCount + batch;
+                if (batch > totalQuants - sampleCount) {
+                    batch = 1;
+                }
+            }
+            ASSERT_EQ(totalQuants, sampleCount);
+        }
+    } else if (s == Status::FILESYSTEM_ERROR) {
+        ASSERT_FALSE(mQueue->isValid());
+        ASSERT_EQ(totalSamples, 0);
+        ASSERT_EQ(railsInSample, 0);
+    } else if (s == Status::NOT_SUPPORTED) {
+        ASSERT_FALSE(mQueue->isValid());
+        ASSERT_EQ(totalSamples, 0);
+        ASSERT_EQ(railsInSample, 0);
+    } else if (s == Status::INVALID_INPUT) {
+        ASSERT_FALSE(mQueue->isValid());
+        ASSERT_EQ(totalSamples, 0);
+        ASSERT_EQ(railsInSample, 0);
+    } else if (s == Status::INSUFFICIENT_RESOURCES) {
+        ASSERT_FALSE(mQueue->isValid());
+        ASSERT_EQ(totalSamples, 0);
+        ASSERT_EQ(railsInSample, 0);
+    }
+}
+
+TEST_F(PowerStatsHidlTest, StreamEnergyData) {
+    std::time_t seed = std::time(nullptr);
+    std::srand(seed);
+    std::thread thread1 = std::thread(readEnergy, service_, std::rand() % 5000);
+    thread1.join();
+}
+
+int main(int argc, char** argv) {
+    ::testing::AddGlobalTestEnvironment(PowerStatsHidlEnv::Instance());
+    ::testing::InitGoogleTest(&argc, argv);
+    PowerStatsHidlEnv::Instance()->init(&argc, argv);
+    int status = RUN_ALL_TESTS();
+    LOG(INFO) << "Test result = " << status;
+    return status;
+}
+}  // namespace vts
+}  // namespace stats
+}  // namespace power
+}  // namespace android
diff --git a/radio/1.0/vts/functional/Android.bp b/radio/1.0/vts/functional/Android.bp
index afbb1c4..9dec2f2 100644
--- a/radio/1.0/vts/functional/Android.bp
+++ b/radio/1.0/vts/functional/Android.bp
@@ -33,6 +33,7 @@
     static_libs: [
         "android.hardware.radio@1.0",
     ],
+    test_suites: ["general-tests"],
 }
 
 cc_test {
@@ -46,6 +47,7 @@
     static_libs: [
         "android.hardware.radio@1.0",
     ],
+    test_suites: ["general-tests"],
 }
 
 cc_library_static {
diff --git a/radio/1.1/vts/functional/Android.bp b/radio/1.1/vts/functional/Android.bp
index e7195ee..5695c6b 100644
--- a/radio/1.1/vts/functional/Android.bp
+++ b/radio/1.1/vts/functional/Android.bp
@@ -30,4 +30,5 @@
     header_libs: [
         "radio.util.header@1.0",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/radio/1.2/vts/functional/Android.bp b/radio/1.2/vts/functional/Android.bp
index a4e8c02..6782f14 100644
--- a/radio/1.2/vts/functional/Android.bp
+++ b/radio/1.2/vts/functional/Android.bp
@@ -31,4 +31,5 @@
         "android.hardware.radio@1.0",
     ],
     header_libs: ["radio.util.header@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/radio/1.3/Android.bp b/radio/1.3/Android.bp
index b6610e0..30b8edf 100644
--- a/radio/1.3/Android.bp
+++ b/radio/1.3/Android.bp
@@ -7,7 +7,6 @@
         enabled: true,
     },
     srcs: [
-        "types.hal",
         "IRadio.hal",
         "IRadioIndication.hal",
         "IRadioResponse.hal",
@@ -17,16 +16,6 @@
         "android.hardware.radio@1.1",
         "android.hardware.radio@1.2",
         "android.hidl.base@1.0",
-        "android.hidl.safe_union@1.0",
-    ],
-    types: [
-        "AccessNetwork",
-        "DataProfileInfo",
-        "DataRegStateResult",
-        "EmergencyNumber",
-        "EmergencyNumberSource",
-        "EmergencyServiceCategory",
-        "LteVopsInfo",
     ],
     gen_java: true,
 }
diff --git a/radio/1.3/IRadio.hal b/radio/1.3/IRadio.hal
index dde9d71..2d64381 100644
--- a/radio/1.3/IRadio.hal
+++ b/radio/1.3/IRadio.hal
@@ -16,14 +16,13 @@
 
 package android.hardware.radio@1.3;
 
-import @1.3::DataProfileInfo;
-import @1.0::Dial;
-import @1.2::DataRequestReason;
 import @1.2::IRadio;
-import @1.3::AccessNetwork;
-import @1.3::EmergencyServiceCategory;
+import @1.1::RadioAccessSpecifier;
 
 /**
+ * Note: IRadio 1.3 is an intermediate layer between Android P and Android Q. It's specifically
+ * designed for CBRS related interfaces. All other interfaces for Q are added in IRadio 1.4.
+ *
  * This interface is used by telephony and telecom to talk to cellular radio.
  * All the functions have minimum one parameter:
  * serial: which corresponds to serial no. of request. Serial numbers must only be memorized for the
@@ -33,93 +32,32 @@
  */
 interface IRadio extends @1.2::IRadio {
     /**
-     * Setup a packet data connection. If DataCallResponse.status returns DataCallFailCause:NONE,
-     * the data connection must be added to data calls and a unsolDataCallListChanged() must be
-     * sent. The call remains until removed by subsequent unsolDataCallIstChanged(). It may be
-     * lost due to many factors, including deactivateDataCall() being issued, the radio powered
-     * off, reception lost or even transient factors like congestion. This data call list is
-     * returned by getDataCallList() and dataCallListChanged().
+     * Specify which bands modem's background scan must act on.
+     * If specifyChannels is true, it only scans bands specified in specifiers.
+     * If specifyChannels is false, it scans all bands.
      *
-     * The Radio is expected to:
-     *   - Create one data call context.
-     *   - Create and configure a dedicated interface for the context.
-     *   - The interface must be point to point.
-     *   - The interface is configured with one or more addresses and is capable of sending and
-     *     receiving packets. The prefix length of the addresses must be /32 for IPv4 and /128
-     *     for IPv6.
-     *   - Must not modify routing configuration related to this interface; routing management is
-     *     exclusively within the purview of the Android OS.
-     *   - Support simultaneous data call contexts up to DataRegStateResult.maxDataCalls specified
-     *     in the response of getDataRegistrationState.
+     * For example, CBRS is only on LTE band 48. By specifying this band,
+     * modem saves more power.
      *
      * @param serial Serial number of request.
-     * @param accessNetwork The access network to setup the data call. If the data connection cannot
-     *     be established on the specified access network, the setup request must be failed.
-     * @param dataProfileInfo Data profile info.
-     * @param roamingAllowed Indicates whether or not data roaming is allowed by the user.
-     * @param reason The request reason. Must be DataRequestReason.NORMAL or
-     *     DataRequestReason.HANDOVER.
-     * @param addresses If the reason is DataRequestReason.HANDOVER, this indicates the list of link
-     *     addresses of the existing data connection. The format is IP address with optional "/"
-     *     prefix length (The format is defined in RFC-4291 section 2.3). For example, "192.0.1.3",
-     *     "192.0.1.11/16", or "2001:db8::1/64". Typically one IPv4 or one IPv6 or one of each. If
-     *     the prefix length is absent, then the addresses are assumed to be point to point with
-     *     IPv4 with prefix length 32 or IPv6 with prefix length 128. This parameter must be ignored
-     *     unless reason is DataRequestReason.HANDOVER.
-     * @param dnses If the reason is DataRequestReason.HANDOVER, this indicates the list of DNS
-     *     addresses of the existing data connection. The format is defined in RFC-4291 section
-     *     2.2. For example, "192.0.1.3" or "2001:db8::1". This parameter must be ignored unless
-     *     reason is DataRequestReason.HANDOVER.
+     * @param specifyChannels whether to scan bands defined in specifiers.
+     * @param specifiers which bands to scan. Only used if specifyChannels is true.
      *
-     * Response function is IRadioResponse.setupDataCallResponse()
-     *
-     * Note this API is same as 1.2 version except using the 1.3 AccessNetwork as the input param.
+     * Response callback is IRadioResponse.setSystemSelectionChannelsResponse()
      */
-    oneway setupDataCall_1_3(int32_t serial, AccessNetwork accessNetwork,
-            DataProfileInfo dataProfileInfo, bool roamingAllowed,
-            DataRequestReason reason, vec<string> addresses, vec<string> dnses);
+    oneway setSystemSelectionChannels(int32_t serial, bool specifyChannels,
+            vec<RadioAccessSpecifier> specifiers);
 
-    /**
-     * Set an apn to initial attach network
-     *
-     * @param serial Serial number of request.
-     * @param dataProfileInfo data profile containing APN settings
-     *
-     * Response callback is IRadioResponse.setInitialAttachApnResponse()
-     */
-    oneway setInitialAttachApn_1_3(int32_t serial, DataProfileInfo dataProfileInfo);
-
-    /**
-     * Send data profiles of the current carrier to the modem.
-     *
-     * @param serial Serial number of request.
-     * @param profiles Array of DataProfile to set.
-     *
-     * Response callback is IRadioResponse.setDataProfileResponse()
-     */
-    oneway setDataProfile_1_3(int32_t serial, vec<DataProfileInfo> profiles);
-
-    /**
-     * Initiate emergency voice call, with zero or more emergency service category(s).
-     *
-     * Note this API is the same as IRadio.dial except using the
-     * @1.3::EmergencyServiceCategory as the input param.
-     *
-     * If the dialed emergency number does not have a specified emergency service category, the
-     * 'categories' field is set to @1.3::EmergencyServiceCategory#UNSPECIFIED; iff either the
-     * 'categories' field is set to @1.3::EmergencyServiceCategory#UNSPECIFIED or the underlying
-     * technology used to request emergency services does not support the emergency service
-     * category, the interpretation of the categories is defined by implementation.
-     *
-     * Reference: 3gpp TS 22.101, Section 10 - Emergency Calls
-     *
-     * @param serial Serial number of request.
-     * @param dialInfo the same @1.0::Dial information used by @1.0::IRadio.dial.
-     * @param categories bitfield<@1.3::EmergencyServiceCategory> the Emergency Service Category(s)
-     *     of the call.
-     *
-     * Response function is IRadioResponse.emergencyDialResponse()
-     */
-    oneway emergencyDial(int32_t serial, Dial dialInfo,
-            bitfield<EmergencyServiceCategory> categories);
+   /**
+    * Toggle logical modem on and off. It should put the logical modem in low power
+    * mode without any activity, while the SIM card remains visible. The difference
+    * with setRadioPower is, setRadioPower affects all logical modem while this controls
+    * just one.
+    *
+    * @param serial Serial number of request.
+    * @param on True to turn on the logical modem, otherwise turn it off.
+    *
+    * Response function is IRadioResponse.enableModemResponse()
+    */
+    oneway enableModem(int32_t serial, bool on);
 };
diff --git a/radio/1.3/IRadioIndication.hal b/radio/1.3/IRadioIndication.hal
index 509eef8..b65d3f2 100644
--- a/radio/1.3/IRadioIndication.hal
+++ b/radio/1.3/IRadioIndication.hal
@@ -16,37 +16,10 @@
 
 package android.hardware.radio@1.3;
 
-import @1.0::RadioIndicationType;
 import @1.2::IRadioIndication;
 
 /**
  * Interface declaring unsolicited radio indications.
  */
 interface IRadioIndication extends @1.2::IRadioIndication {
-    /**
-     * Report the current list of emergency numbers
-     *
-     * Each emergency number (@1.3::EmergencyNumber) in the emergency number list contains a
-     * dialing number, zero or more service category(s), mobile country code, and source(s) that
-     * indicate where it comes from.
-     *
-     * Radio must report all the valid emergency numbers with known mobile country code and
-     * emergency service categories from all available sources including network signaling, sim,
-     * modem/oem configuration, and default configuration (112 and 911 must be always available;
-     * additionally, 000, 08, 110, 999, 118 and 119 must be available when sim is not present).
-     * Radio shall not report emergency numbers that are invalid in the current locale. The
-     * reported emergency number list must not have duplicate @1.3::EmergencyNumber entries. Please
-     * refer the documentation of @1.3::EmergencyNumber to construct each emergency number to
-     * report.
-     *
-     * Radio must report the complete list of emergency numbers whenever the emergency numbers in
-     * the list are changed or whenever the client and the radio server are connected.
-     *
-     * Reference: 3gpp 22.101, Section 10 - Emergency Calls
-     *
-     * @param type Type of radio indication
-     * @param emergencyNumberList Current list of emergency numbers known to radio.
-     */
-    oneway currentEmergencyNumberList(RadioIndicationType type,
-            vec<EmergencyNumber> emergencyNumberList);
 };
diff --git a/radio/1.3/IRadioResponse.hal b/radio/1.3/IRadioResponse.hal
index 10e7d63..abdf2ee 100644
--- a/radio/1.3/IRadioResponse.hal
+++ b/radio/1.3/IRadioResponse.hal
@@ -16,10 +16,13 @@
 
 package android.hardware.radio@1.3;
 
-import @1.0::RadioResponseInfo;
 import @1.2::IRadioResponse;
+import @1.0::RadioResponseInfo;
 
 /**
+ * Note: IRadio 1.3 is an intermediate layer between Android P and Android Q. It's specifically
+ * designed for CBRS related interfaces. All other interfaces for Q are added in IRadio 1.4.
+ *
  * Interface declaring response functions to solicited radio requests.
  */
 interface IRadioResponse extends @1.2::IRadioResponse {
@@ -28,37 +31,19 @@
      *
      * Valid errors returned:
      *   RadioError:NONE
-     *   RadioError:RADIO_NOT_AVAILABLE (radio resetting)
-     *   RadioError:DIAL_MODIFIED_TO_USSD
-     *   RadioError:DIAL_MODIFIED_TO_SS
-     *   RadioError:DIAL_MODIFIED_TO_DIAL
-     *   RadioError:INVALID_ARGUMENTS
-     *   RadioError:NO_MEMORY
-     *   RadioError:NO_RESOURCES
+     *   RadioError:RADIO_NOT_AVAILABLE
      *   RadioError:INTERNAL_ERR
-     *   RadioError:FDN_CHECK_FAILURE
-     *   RadioError:MODEM_ERR
-     *   RadioError:NO_SUBSCRIPTION
-     *   RadioError:NO_NETWORK_FOUND
-     *   RadioError:INVALID_CALL_ID
-     *   RadioError:DEVICE_IN_USE
-     *   RadioError:ABORTED
-     *   RadioError:INVALID_MODEM_STATE
-     *   RadioError:CANCELLED
+     *   RadioError:INVALID_ARGUMENTS
      */
-    oneway emergencyDialResponse(RadioResponseInfo info);
+    oneway setSystemSelectionChannelsResponse(RadioResponseInfo info);
 
     /**
      * @param info Response info struct containing response type, serial no. and error
-     * @param dataRegResponse Current Data registration response as defined by DataRegStateResult in
-     *        types.hal
      *
      * Valid errors returned:
      *   RadioError:NONE
      *   RadioError:RADIO_NOT_AVAILABLE
      *   RadioError:INTERNAL_ERR
-     *   RadioError:NOT_PROVISIONED
      */
-    oneway getDataRegistrationStateResponse_1_3(RadioResponseInfo info,
-            DataRegStateResult dataRegResponse);
+    oneway enableModemResponse(RadioResponseInfo info);
 };
diff --git a/radio/1.3/types.hal b/radio/1.3/types.hal
deleted file mode 100644
index 8b0891c..0000000
--- a/radio/1.3/types.hal
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.hardware.radio@1.3;
-
-import @1.0::ApnAuthType;
-import @1.0::ApnTypes;
-import @1.0::DataProfileId;
-import @1.0::DataProfileInfoType;
-import @1.0::RadioAccessFamily;
-import @1.0::RegState;
-import @1.2::AccessNetwork;
-import @1.2::CellIdentity;
-import @1.2::DataRegStateResult;
-
-import android.hidl.safe_union@1.0::Monostate;
-
-enum AccessNetwork : @1.2::AccessNetwork {
-    /**
-     * Unknown access network
-     */
-    UNKNOWN = 0,
-};
-
-/**
- * Emergency number contains information of number, one or more service category(s), mobile country
- * code (mcc), and source(s) that indicate where it comes from.
- *
- * If the source of the emergency number is associated with country, field ‘mcc’ must be
- * provided; otherwise the field ‘mcc’ must be an empty string.
- *
- * A unique EmergencyNumber has a unique combination of ‘number’, ‘mcc’ and 'categories' fields.
- * Multiple @1.3::EmergencyNumberSource should be merged into the bitfield for the same
- * EmergencyNumber.
- *
- * Reference: 3GPP TS 22.101 version 9.1.0 Release 9
- */
-struct EmergencyNumber{
-    /**
-     * The emergency number. The character in the number string should only be the dial pad
-     * character('0'-'9', '*', or '#'). For example: 911.
-     */
-    string number;
-    /**
-     * 3-digit Mobile Country Code, 0..999. Empty string if not applicable.
-     */
-    string mcc;
-    /**
-     * The bitfield of @1.3::EmergencyServiceCategory(s). See @1.3::EmergencyServiceCategory for
-     * the value of each bit.
-     */
-    bitfield<EmergencyServiceCategory> categories;
-    /**
-     * The bitfield of @1.3::EmergencyNumberSource(s). See @1.3::EmergencyNumberSource for the
-     * value of each bit.
-     */
-    bitfield<EmergencyNumberSource> sources;
-};
-
-/**
- * Defining Emergency Service Category as follows:
- * - General emergency call, all categories;
- * - Police;
- * - Ambulance;
- * - Fire Brigade;
- * - Marine Guard;
- * - Mountain Rescue;
- * - Manually Initiated eCall (MIeC);
- * - Automatically Initiated eCall (AIeC);
- *
- * Category UNSPECIFIED (General emergency call, all categories) indicates that no specific
- * services are associated with this emergency number.
- *
- * Reference: 3gpp 22.101, Section 10 - Emergency Calls
- */
-enum EmergencyServiceCategory : int32_t {
-    /**
-     * General emergency call, all categories
-     */
-    UNSPECIFIED = 0,
-    POLICE = 1 << 0,
-    AMBULANCE = 1 << 1,
-    FIRE_BRIGADE = 1 << 2,
-    MARINE_GUARD = 1 << 3,
-    MOUNTAIN_RESCUE = 1 << 4,
-    /**
-     * Manually Initiated eCall (MIeC)
-     */
-    MIEC = 1 << 5,
-    /**
-     * Automatically Initiated eCall (AIeC)
-     */
-    AIEC = 1 << 6,
-};
-
-/**
- * The source to tell where the corresponding @1.3::EmergencyNumber comes from.
- *
- * Reference: 3gpp 22.101, Section 10 - Emergency Calls
- */
-enum EmergencyNumberSource : int32_t {
-    /**
-     * Indicates the number is from the network signal.
-     */
-    NETWORK_SIGNALING = 1 << 0,
-    /**
-     * Indicates the number is from the sim card.
-     */
-    SIM = 1 << 1,
-    /**
-     * Indicates the number is from the modem config.
-     */
-    MODEM_CONFIG = 1 << 2,
-    /**
-     * Indicates the number is available as default. Per the reference, 112, 911 must always be
-     * available; additionally, 000, 08, 110, 999, 118 and 119 must be available when sim is not
-     * present.
-     */
-    DEFAULT = 1 << 3,
-};
-
-/**
- * Type to define the LTE specific network capabilities for voice over PS including
- * emergency and normal voice calls.
- */
-struct LteVopsInfo {
-    /**
-     * This indicates if camped network support VoLTE services. This information is received
-     * from LTE network during LTE NAS registration procedure through LTE ATTACH ACCEPT/TAU
-     * ACCEPT. Refer 3GPP 24.301 EPS network feature support -> IMS VoPS
-     */
-    bool isVopsSupported;
-    /**
-     * This indicates if camped network support VoLTE emergency bearers. This information
-     * is received from LTE network through two sources:
-     * a. During LTE NAS registration procedure through LTE ATTACH ACCEPT/TAU ACCEPT. Refer
-     *    3GPP 24.301 EPS network feature support -> EMC BS
-     * b. In case device is not registered on network. Refer 3GPP 25.331 LTE RRC
-     *    SIB1 : ims-EmergencySupport-r9
-     * If device is registered on LTE, then this field indicates (a).
-     * In case of limited service on LTE this field indicates (b).
-     */
-    bool isEmcBearerSupported;
-};
-
-struct DataRegStateResult {
-    @1.2::DataRegStateResult base;
-    /**
-     * Network capabilities for voice over PS services. This info is valid only
-     * on LTE network and must be present when device is camped on LTE. vopsInfo
-     * will be empty when device is camped only on 2G/3G .
-     */
-    safe_union VopsInfo {
-        Monostate noinit;
-
-        LteVopsInfo lteVopsInfo; // LTE network capability
-    } vopsInfo;
-};
-
-/**
- * Overwritten from @1.0::DataProfileInfo in order to deprecate 'mvnoType', and 'mvnoMatchData'.
- * In the future, this must be extended instead of overwritten.
- * Also added 'preferred' and 'persistent' in this version.
- */
-struct DataProfileInfo {
-    /** id of the data profile */
-    DataProfileId profileId;
-
-    /** The APN name */
-    string apn;
-
-    /**
-     * One of the PDP_type values in TS 27.007 section 10.1.1. For example, "IP", "IPV6", "IPV4V6",
-     * or "PPP".
-     */
-    string protocol;
-
-    /**
-     * one of the PDP_type values in TS 27.007 section 10.1.1 used on roaming network. For example,
-     * "IP", "IPV6", "IPV4V6", or "PPP".
-     */
-    string roamingProtocol;
-
-    /** APN authentication type */
-    ApnAuthType authType;
-
-    /** The username for APN, or empty string */
-    string user;
-
-    /** The password for APN, or empty string */
-    string password;
-
-    /** Data profile technology type */
-    DataProfileInfoType type;
-
-    /** The period in seconds to limit the maximum connections */
-    int32_t maxConnsTime;
-
-    /** The maximum connections during maxConnsTime */
-    int32_t maxConns;
-
-    /**
-     * The required wait time in seconds after a successful UE initiated disconnect of a given PDN
-     * connection before the device can send a new PDN connection request for that given PDN.
-     */
-    int32_t waitTime;
-
-    /** True to enable the profile, false to disable */
-    bool enabled;
-
-    /** Supported APN types bitmap. See ApnTypes for the value of each bit. */
-    bitfield<ApnTypes> supportedApnTypesBitmap;
-
-    /** The bearer bitmap. See RadioAccessFamily for the value of each bit. */
-    bitfield<RadioAccessFamily> bearerBitmap;
-
-    /** Maximum transmission unit (MTU) size in bytes */
-    int32_t mtu;
-
-    /**
-     * True if this data profile was used to bring up the last default (i.e internet) data
-     * connection successfully.
-     */
-    bool preferred;
-
-    /**
-     * If true, modem must persist this data profile and profileId must not be
-     * set to DataProfileId.INVALID. If the same data profile exists, this data profile must
-     * overwrite it.
-     */
-    bool persistent;
-};
diff --git a/radio/1.4/Android.bp b/radio/1.4/Android.bp
new file mode 100644
index 0000000..c2ba47e
--- /dev/null
+++ b/radio/1.4/Android.bp
@@ -0,0 +1,44 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.radio@1.4",
+    root: "android.hardware",
+    vndk: {
+        enabled: true,
+    },
+    srcs: [
+        "types.hal",
+        "IRadio.hal",
+        "IRadioIndication.hal",
+        "IRadioResponse.hal",
+    ],
+    interfaces: [
+        "android.hardware.radio@1.0",
+        "android.hardware.radio@1.1",
+        "android.hardware.radio@1.2",
+        "android.hardware.radio@1.3",
+        "android.hidl.base@1.0",
+        "android.hidl.safe_union@1.0",
+    ],
+    types: [
+        "AccessNetwork",
+        "CardStatus",
+        "CellConfigLte",
+        "CellInfo",
+        "CellInfoLte",
+        "DataProfileInfo",
+        "DataRegStateResult",
+        "EmergencyNumber",
+        "EmergencyNumberSource",
+        "EmergencyServiceCategory",
+        "FrequencyRange",
+        "LteVopsInfo",
+        "NetworkScanResult",
+        "PhysicalChannelConfig",
+        "RadioFrequencyInfo",
+        "RadioTechnology",
+        "NrIndicators",
+    ],
+    gen_java: true,
+}
+
diff --git a/radio/1.4/IRadio.hal b/radio/1.4/IRadio.hal
new file mode 100644
index 0000000..8854453
--- /dev/null
+++ b/radio/1.4/IRadio.hal
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.radio@1.4;
+
+import @1.0::Dial;
+import @1.2::DataRequestReason;
+import @1.3::IRadio;
+import @1.4::AccessNetwork;
+import @1.4::DataProfileInfo;
+import @1.4::EmergencyServiceCategory;
+
+/**
+ * This interface is used by telephony and telecom to talk to cellular radio.
+ * All the functions have minimum one parameter:
+ * serial: which corresponds to serial no. of request. Serial numbers must only be memorized for the
+ * duration of a method call. If clients provide colliding serials (including passing the same
+ * serial to different methods), multiple responses (one for each method call) must still be served.
+ * setResponseFunctions must work with @1.1::IRadioResponse and @1.1::IRadioIndication.
+ */
+interface IRadio extends @1.3::IRadio {
+    /**
+     * Setup a packet data connection. If DataCallResponse.status returns DataCallFailCause:NONE,
+     * the data connection must be added to data calls and a unsolDataCallListChanged() must be
+     * sent. The call remains until removed by subsequent unsolDataCallIstChanged(). It may be
+     * lost due to many factors, including deactivateDataCall() being issued, the radio powered
+     * off, reception lost or even transient factors like congestion. This data call list is
+     * returned by getDataCallList() and dataCallListChanged().
+     *
+     * The Radio is expected to:
+     *   - Create one data call context.
+     *   - Create and configure a dedicated interface for the context.
+     *   - The interface must be point to point.
+     *   - The interface is configured with one or more addresses and is capable of sending and
+     *     receiving packets. The prefix length of the addresses must be /32 for IPv4 and /128
+     *     for IPv6.
+     *   - Must not modify routing configuration related to this interface; routing management is
+     *     exclusively within the purview of the Android OS.
+     *   - Support simultaneous data call contexts up to DataRegStateResult.maxDataCalls specified
+     *     in the response of getDataRegistrationState.
+     *
+     * @param serial Serial number of request.
+     * @param accessNetwork The access network to setup the data call. If the data connection cannot
+     *     be established on the specified access network, the setup request must be failed.
+     * @param dataProfileInfo Data profile info.
+     * @param roamingAllowed Indicates whether or not data roaming is allowed by the user.
+     * @param reason The request reason. Must be DataRequestReason.NORMAL or
+     *     DataRequestReason.HANDOVER.
+     * @param addresses If the reason is DataRequestReason.HANDOVER, this indicates the list of link
+     *     addresses of the existing data connection. The format is IP address with optional "/"
+     *     prefix length (The format is defined in RFC-4291 section 2.3). For example, "192.0.1.3",
+     *     "192.0.1.11/16", or "2001:db8::1/64". Typically one IPv4 or one IPv6 or one of each. If
+     *     the prefix length is absent, then the addresses are assumed to be point to point with
+     *     IPv4 with prefix length 32 or IPv6 with prefix length 128. This parameter must be ignored
+     *     unless reason is DataRequestReason.HANDOVER.
+     * @param dnses If the reason is DataRequestReason.HANDOVER, this indicates the list of DNS
+     *     addresses of the existing data connection. The format is defined in RFC-4291 section
+     *     2.2. For example, "192.0.1.3" or "2001:db8::1". This parameter must be ignored unless
+     *     reason is DataRequestReason.HANDOVER.
+     *
+     * Response function is IRadioResponse.setupDataCallResponse()
+     *
+     * Note this API is same as 1.2 version except using the 1.4 AccessNetwork as the input param.
+     */
+    oneway setupDataCall_1_4(int32_t serial, AccessNetwork accessNetwork,
+            DataProfileInfo dataProfileInfo, bool roamingAllowed,
+            DataRequestReason reason, vec<string> addresses, vec<string> dnses);
+
+    /**
+     * Set an apn to initial attach network
+     *
+     * @param serial Serial number of request.
+     * @param dataProfileInfo data profile containing APN settings
+     *
+     * Response callback is IRadioResponse.setInitialAttachApnResponse()
+     */
+    oneway setInitialAttachApn_1_4(int32_t serial, DataProfileInfo dataProfileInfo);
+
+    /**
+     * Send data profiles of the current carrier to the modem.
+     *
+     * @param serial Serial number of request.
+     * @param profiles Array of DataProfile to set.
+     *
+     * Response callback is IRadioResponse.setDataProfileResponse()
+     */
+    oneway setDataProfile_1_4(int32_t serial, vec<DataProfileInfo> profiles);
+
+    /**
+     * Initiate emergency voice call, with zero or more emergency service category(s).
+     *
+     * Note this API is the same as IRadio.dial except using the
+     * @1.4::EmergencyServiceCategory as the input param.
+     *
+     * If the dialed emergency number does not have a specified emergency service category, the
+     * 'categories' field is set to @1.4::EmergencyServiceCategory#UNSPECIFIED; iff either the
+     * 'categories' field is set to @1.4::EmergencyServiceCategory#UNSPECIFIED or the underlying
+     * technology used to request emergency services does not support the emergency service
+     * category, the interpretation of the categories is defined by implementation.
+     *
+     * Reference: 3gpp TS 22.101, Section 10 - Emergency Calls
+     *
+     * @param serial Serial number of request.
+     * @param dialInfo the same @1.0::Dial information used by @1.0::IRadio.dial.
+     * @param categories bitfield<@1.4::EmergencyServiceCategory> the Emergency Service Category(s)
+     *     of the call.
+     *
+     * Response function is IRadioResponse.emergencyDialResponse()
+     */
+    oneway emergencyDial(int32_t serial, Dial dialInfo,
+            bitfield<EmergencyServiceCategory> categories);
+};
diff --git a/radio/1.4/IRadioIndication.hal b/radio/1.4/IRadioIndication.hal
new file mode 100644
index 0000000..fac77f7
--- /dev/null
+++ b/radio/1.4/IRadioIndication.hal
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.radio@1.4;
+
+import @1.0::RadioIndicationType;
+import @1.3::IRadioIndication;
+
+/**
+ * Interface declaring unsolicited radio indications.
+ */
+interface IRadioIndication extends @1.3::IRadioIndication {
+    /**
+     * Report the current list of emergency numbers
+     *
+     * Each emergency number (@1.4::EmergencyNumber) in the emergency number list contains a
+     * dialing number, zero or more service category(s), mobile country code, and source(s) that
+     * indicate where it comes from.
+     *
+     * Radio must report all the valid emergency numbers with known mobile country code and
+     * emergency service categories from all available sources including network signaling, sim,
+     * modem/oem configuration, and default configuration (112 and 911 must be always available;
+     * additionally, 000, 08, 110, 999, 118 and 119 must be available when sim is not present).
+     * Radio shall not report emergency numbers that are invalid in the current locale. The
+     * reported emergency number list must not have duplicate @1.4::EmergencyNumber entries. Please
+     * refer the documentation of @1.4::EmergencyNumber to construct each emergency number to
+     * report.
+     *
+     * Radio must report the complete list of emergency numbers whenever the emergency numbers in
+     * the list are changed or whenever the client and the radio server are connected.
+     *
+     * Reference: 3gpp 22.101, Section 10 - Emergency Calls
+     *
+     * @param type Type of radio indication
+     * @param emergencyNumberList Current list of emergency numbers known to radio.
+     */
+    oneway currentEmergencyNumberList(RadioIndicationType type,
+            vec<EmergencyNumber> emergencyNumberList);
+
+    /**
+     * Request all of the current cell information known to the radio.
+     *
+     * @param type Type of radio indication
+     * @param records Current cell information
+     */
+    oneway cellInfoList_1_4(RadioIndicationType type, vec<CellInfo> records);
+
+    /**
+     * Incremental network scan results
+     */
+    oneway networkScanResult_1_4(RadioIndicationType type, NetworkScanResult result);
+
+    /**
+     * Indicates physical channel configurations.
+     *
+     * An empty configs list indicates that the radio is in idle mode.
+     *
+     * @param type Type of radio indication
+     * @param configs Vector of PhysicalChannelConfigs
+     */
+    oneway currentPhysicalChannelConfigs_1_4(RadioIndicationType type,
+            vec<PhysicalChannelConfig> configs);
+};
\ No newline at end of file
diff --git a/radio/1.4/IRadioResponse.hal b/radio/1.4/IRadioResponse.hal
new file mode 100644
index 0000000..d971850
--- /dev/null
+++ b/radio/1.4/IRadioResponse.hal
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.radio@1.4;
+
+import @1.0::RadioResponseInfo;
+import @1.3::IRadioResponse;
+
+/**
+ * Interface declaring response functions to solicited radio requests.
+ */
+interface IRadioResponse extends @1.3::IRadioResponse {
+    /**
+     * @param info Response info struct containing response type, serial no. and error
+     *
+     * Valid errors returned:
+     *   RadioError:NONE
+     *   RadioError:RADIO_NOT_AVAILABLE (radio resetting)
+     *   RadioError:DIAL_MODIFIED_TO_USSD
+     *   RadioError:DIAL_MODIFIED_TO_SS
+     *   RadioError:DIAL_MODIFIED_TO_DIAL
+     *   RadioError:INVALID_ARGUMENTS
+     *   RadioError:NO_MEMORY
+     *   RadioError:NO_RESOURCES
+     *   RadioError:INTERNAL_ERR
+     *   RadioError:FDN_CHECK_FAILURE
+     *   RadioError:MODEM_ERR
+     *   RadioError:NO_SUBSCRIPTION
+     *   RadioError:NO_NETWORK_FOUND
+     *   RadioError:INVALID_CALL_ID
+     *   RadioError:DEVICE_IN_USE
+     *   RadioError:ABORTED
+     *   RadioError:INVALID_MODEM_STATE
+     *   RadioError:CANCELLED
+     */
+    oneway emergencyDialResponse(RadioResponseInfo info);
+
+    /**
+     * @param info Response info struct containing response type, serial no. and error
+     * @param cellInfo List of current cell information known to radio
+     *
+     * Valid errors returned:
+     *   RadioError:NONE
+     *   RadioError:RADIO_NOT_AVAILABLE
+     *   RadioError:INTERNAL_ERR
+     */
+    oneway getCellInfoListResponse_1_4(RadioResponseInfo info, vec<CellInfo> cellInfo);
+
+    /**
+     * @param info Response info struct containing response type, serial no. and error
+     * @param dataRegResponse Current Data registration response as defined by DataRegStateResult in
+     *        types.hal
+     *
+     * Valid errors returned:
+     *   RadioError:NONE
+     *   RadioError:RADIO_NOT_AVAILABLE
+     *   RadioError:INTERNAL_ERR
+     *   RadioError:NOT_PROVISIONED
+     */
+    oneway getDataRegistrationStateResponse_1_4(RadioResponseInfo info,
+            DataRegStateResult dataRegResponse);
+
+    /**
+     * @param info Response info struct containing response type, serial no. and error
+     * @param cardStatus ICC card status as defined by CardStatus in types.hal
+     *
+     * Valid errors returned:
+     *   RadioError:NONE
+     *   RadioError:RADIO_NOT_AVAILABLE
+     *   RadioError:INTERNAL_ERR
+     *   RadioError:NO_MEMORY
+     *   RadioError:NO_RESOURCES
+     *   RadioError:CANCELLED
+     *   RadioError:REQUEST_NOT_SUPPORTED
+     */
+    oneway getIccCardStatusResponse_1_4(RadioResponseInfo info, CardStatus cardStatus);
+};
\ No newline at end of file
diff --git a/radio/1.4/types.hal b/radio/1.4/types.hal
new file mode 100644
index 0000000..4e5b288
--- /dev/null
+++ b/radio/1.4/types.hal
@@ -0,0 +1,422 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.radio@1.4;
+
+import @1.0::ApnAuthType;
+import @1.0::ApnTypes;
+import @1.0::CellInfoType;
+import @1.0::DataProfileId;
+import @1.0::DataProfileInfoType;
+import @1.0::RadioAccessFamily;
+import @1.0::RadioError;
+import @1.0::RadioTechnology;
+import @1.0::RegState;
+import @1.0::TimeStampType;
+import @1.1::ScanStatus;
+import @1.2::AccessNetwork;
+import @1.2::CellInfo;
+import @1.2::CellInfoCdma;
+import @1.2::CellInfoGsm;
+import @1.2::CellInfoLte;
+import @1.2::CellInfoTdscdma;
+import @1.2::CellInfoWcdma;
+import @1.2::CardStatus;
+import @1.2::CellIdentity;
+import @1.2::DataRegStateResult;
+import @1.2::PhysicalChannelConfig;
+
+import android.hidl.safe_union@1.0::Monostate;
+
+enum AccessNetwork : @1.2::AccessNetwork {
+    /**
+     * Unknown access network
+     */
+    UNKNOWN = 0,
+};
+
+/**
+ * Emergency number contains information of number, one or more service category(s), mobile country
+ * code (mcc), and source(s) that indicate where it comes from.
+ *
+ * If the source of the emergency number is associated with country, field ‘mcc’ must be
+ * provided; otherwise the field ‘mcc’ must be an empty string.
+ *
+ * A unique EmergencyNumber has a unique combination of ‘number’, ‘mcc’ and 'categories' fields.
+ * Multiple @1.4::EmergencyNumberSource should be merged into the bitfield for the same
+ * EmergencyNumber.
+ *
+ * Reference: 3GPP TS 22.101 version 9.1.0 Release 9
+ */
+struct EmergencyNumber{
+    /**
+     * The emergency number. The character in the number string should only be the dial pad
+     * character('0'-'9', '*', or '#'). For example: 911.
+     */
+    string number;
+    /**
+     * 3-digit Mobile Country Code, 0..999. Empty string if not applicable.
+     */
+    string mcc;
+    /**
+     * The bitfield of @1.4::EmergencyServiceCategory(s). See @1.4::EmergencyServiceCategory for
+     * the value of each bit.
+     */
+    bitfield<EmergencyServiceCategory> categories;
+    /**
+     * The bitfield of @1.4::EmergencyNumberSource(s). See @1.4::EmergencyNumberSource for the
+     * value of each bit.
+     */
+    bitfield<EmergencyNumberSource> sources;
+};
+
+/**
+ * Defining Emergency Service Category as follows:
+ * - General emergency call, all categories;
+ * - Police;
+ * - Ambulance;
+ * - Fire Brigade;
+ * - Marine Guard;
+ * - Mountain Rescue;
+ * - Manually Initiated eCall (MIeC);
+ * - Automatically Initiated eCall (AIeC);
+ *
+ * Category UNSPECIFIED (General emergency call, all categories) indicates that no specific
+ * services are associated with this emergency number.
+ *
+ * Reference: 3gpp 22.101, Section 10 - Emergency Calls
+ */
+enum EmergencyServiceCategory : int32_t {
+    /**
+     * General emergency call, all categories
+     */
+    UNSPECIFIED = 0,
+    POLICE = 1 << 0,
+    AMBULANCE = 1 << 1,
+    FIRE_BRIGADE = 1 << 2,
+    MARINE_GUARD = 1 << 3,
+    MOUNTAIN_RESCUE = 1 << 4,
+    /**
+     * Manually Initiated eCall (MIeC)
+     */
+    MIEC = 1 << 5,
+    /**
+     * Automatically Initiated eCall (AIeC)
+     */
+    AIEC = 1 << 6,
+};
+
+/**
+ * The source to tell where the corresponding @1.4::EmergencyNumber comes from.
+ *
+ * Reference: 3gpp 22.101, Section 10 - Emergency Calls
+ */
+enum EmergencyNumberSource : int32_t {
+    /**
+     * Indicates the number is from the network signal.
+     */
+    NETWORK_SIGNALING = 1 << 0,
+    /**
+     * Indicates the number is from the sim card.
+     */
+    SIM = 1 << 1,
+    /**
+     * Indicates the number is from the modem config.
+     */
+    MODEM_CONFIG = 1 << 2,
+    /**
+     * Indicates the number is available as default. Per the reference, 112, 911 must always be
+     * available; additionally, 000, 08, 110, 999, 118 and 119 must be available when sim is not
+     * present.
+     */
+    DEFAULT = 1 << 3,
+};
+
+enum RadioTechnology : @1.0::RadioTechnology {
+    /** 5G NR. */
+    NR = 20,
+};
+
+/** Mapping the frequency to a rough range. */
+enum FrequencyRange : int32_t {
+    /** Indicates the frequency range is below 1GHz. */
+    LOW = 1,
+
+    /** Indicates the frequency range is between 1GHz and 3GHz. */
+    MID = 2,
+
+    /** Indicates the frequency range is between 3GHz and 6GHz. */
+    HIGH = 3,
+
+    /** Indicates the frequency range is above 6GHz (millimeter wave frequency). */
+    MMWAVE = 4,
+};
+
+safe_union RadioFrequencyInfo {
+    /** A rough frequency range. */
+    FrequencyRange range;
+
+    /** The Absolute Radio Frequency Channel Number. */
+    int32_t channelNumber;
+};
+
+struct PhysicalChannelConfig {
+    @1.2::PhysicalChannelConfig base;
+
+    /** The radio technology for this physical channel. */
+    RadioTechnology rat;
+
+    /** The radio frequency info. */
+    RadioFrequencyInfo rfInfo;
+
+    /**
+     * A list of data calls mapped to this physical channel. The context id must match the cid of
+     * @1.0::SetupDataCallResult. An empty list means the physical channel has no data call mapped
+     * to it.
+     */
+    vec<int32_t> contextIds;
+
+    /**
+     * The physical cell identifier for this cell.
+     *
+     * In UTRAN, this value is primary scrambling code. The range is [0, 511].
+     * Reference: 3GPP TS 25.213 section 5.2.2.
+     *
+     * In EUTRAN, this value is physical layer cell identity. The range is [0, 503].
+     * Reference: 3GPP TS 36.211 section 6.11.
+     *
+     * In 5G RAN, this value is physical layer cell identity. The range is [0, 1008].
+     * Reference: 3GPP TS 38.211 section 7.4.2.1.
+     */
+    uint32_t physicalCellId;
+};
+
+/**
+ * Type to define the LTE specific network capabilities for voice over PS including
+ * emergency and normal voice calls.
+ */
+struct LteVopsInfo {
+    /**
+     * This indicates if camped network support VoLTE services. This information is received
+     * from LTE network during LTE NAS registration procedure through LTE ATTACH ACCEPT/TAU
+     * ACCEPT. Refer 3GPP 24.301 EPS network feature support -> IMS VoPS
+     */
+    bool isVopsSupported;
+    /**
+     * This indicates if camped network support VoLTE emergency bearers. This information
+     * is received from LTE network through two sources:
+     * a. During LTE NAS registration procedure through LTE ATTACH ACCEPT/TAU ACCEPT. Refer
+     *    3GPP 24.301 EPS network feature support -> EMC BS
+     * b. In case device is not registered on network. Refer 3GPP 25.331 LTE RRC
+     *    SIB1 : ims-EmergencySupport-r9
+     * If device is registered on LTE, then this field indicates (a).
+     * In case of limited service on LTE this field indicates (b).
+     */
+    bool isEmcBearerSupported;
+};
+
+/** The parameters of NR 5G Non-Standalone. */
+struct NrIndicators {
+    /**
+     * Indicates that if E-UTRA-NR Dual Connectivity (EN-DC) is supported by the primary serving
+     * cell.
+     *
+     * True the primary serving cell is LTE cell and the plmn-InfoList-r15 is present in SIB2 and
+     * at least one bit in this list is true, otherwise this value should be false.
+     *
+     * Reference: 3GPP TS 36.331 v15.2.2 6.3.1 System information blocks.
+     */
+    bool isEndcAvailable;
+
+    /**
+     * True if use of dual connectivity with NR is restricted.
+     * Reference: 3GPP TS 24.301 v15.03 section 9.3.3.12A.
+     */
+    bool isDcNrRestricted;
+
+    /**
+     * True if the bit N is in the PLMN-InfoList-r15 is true and the selected PLMN is present in
+     * plmn-IdentityList at position N.
+     * Reference: 3GPP TS 36.331 v15.2.2 section 6.3.1 PLMN-InfoList-r15.
+     *            3GPP TS 36.331 v15.2.2 section 6.2.2 SystemInformationBlockType1 message.
+     */
+    bool isNrAvailable;
+};
+
+struct DataRegStateResult {
+    @1.2::DataRegStateResult base;
+
+    /**
+     * Network capabilities for voice over PS services. This info is valid only on LTE network and
+     * must be present when device is camped on LTE. vopsInfo must be empty when device is camped
+     * only on 2G/3G.
+     */
+    safe_union VopsInfo {
+        Monostate noinit;
+
+        LteVopsInfo lteVopsInfo; // LTE network capability
+    } vopsInfo;
+
+    /**
+     * The parameters of NR 5G Non-Standalone. This value is only valid on E-UTRAN, otherwise
+     * must be empty.
+     */
+    NrIndicators nrIndicators;
+};
+
+/** Contains the configuration of the LTE cell tower. */
+struct CellConfigLte {
+    /**
+     * Indicates that if E-UTRA-NR Dual Connectivity (EN-DC) is supported by the LTE cell.
+     *
+     * True if the plmn-InfoList-r15 is present in SIB2 and at least one bit in this list is true,
+     * otherwise this value should be false.
+     *
+     * Reference: 3GPP TS 36.331 v15.2.2 6.3.1 System information blocks.
+     */
+    bool isEndcAvailable;
+};
+
+/** Inherits from @1.2::CellInfoLte, in order to add the LTE configuration. */
+struct CellInfoLte {
+    @1.2::CellInfoLte base;
+    CellConfigLte cellConfig;
+};
+
+/** Overwritten from @1.2::CellInfo in order to update the CellInfoLte to 1.4 version. */
+struct CellInfo {
+    /** Cell type for selecting from union CellInfo. */
+    CellInfoType cellInfoType;
+
+    /**
+     * True if the phone is registered to a mobile network that provides service on this cell and
+     * this cell is being used or would be used for network signaling.
+     */
+    bool isRegistered;
+
+    /** CellInfo details, cellInfoType can tell which cell info should be used. */
+    safe_union Info {
+        CellInfoGsm gsm;
+        CellInfoCdma cdma;
+        CellInfoWcdma wcdma;
+        CellInfoTdscdma tdscdma;
+        CellInfoLte lte;
+    } info;
+};
+
+/** Overwritten from @1.2::NetworkScanResult in order to update the CellInfo to 1.4 version. */
+struct NetworkScanResult {
+    /**
+     * The status of the scan.
+     */
+    ScanStatus status;
+
+    /**
+     * The error code of the incremental result.
+     */
+    RadioError error;
+
+    /**
+     * List of network information as CellInfo.
+     */
+    vec<CellInfo> networkInfos;
+};
+
+/**
+ * Overwritten from @1.0::DataProfileInfo in order to deprecate 'mvnoType', and 'mvnoMatchData'.
+ * In the future, this must be extended instead of overwritten.
+ * Also added 'preferred' and 'persistent' in this version.
+ */
+struct DataProfileInfo {
+    /** id of the data profile */
+    DataProfileId profileId;
+
+    /** The APN name */
+    string apn;
+
+    /**
+     * One of the PDP_type values in TS 27.007 section 10.1.1. For example, "IP", "IPV6", "IPV4V6",
+     * or "PPP".
+     */
+    string protocol;
+
+    /**
+     * one of the PDP_type values in TS 27.007 section 10.1.1 used on roaming network. For example,
+     * "IP", "IPV6", "IPV4V6", or "PPP".
+     */
+    string roamingProtocol;
+
+    /** APN authentication type */
+    ApnAuthType authType;
+
+    /** The username for APN, or empty string */
+    string user;
+
+    /** The password for APN, or empty string */
+    string password;
+
+    /** Data profile technology type */
+    DataProfileInfoType type;
+
+    /** The period in seconds to limit the maximum connections */
+    int32_t maxConnsTime;
+
+    /** The maximum connections during maxConnsTime */
+    int32_t maxConns;
+
+    /**
+     * The required wait time in seconds after a successful UE initiated disconnect of a given PDN
+     * connection before the device can send a new PDN connection request for that given PDN.
+     */
+    int32_t waitTime;
+
+    /** True to enable the profile, false to disable */
+    bool enabled;
+
+    /** Supported APN types bitmap. See ApnTypes for the value of each bit. */
+    bitfield<ApnTypes> supportedApnTypesBitmap;
+
+    /** The bearer bitmap. See RadioAccessFamily for the value of each bit. */
+    bitfield<RadioAccessFamily> bearerBitmap;
+
+    /** Maximum transmission unit (MTU) size in bytes */
+    int32_t mtu;
+
+    /**
+     * True if this data profile was used to bring up the last default (i.e internet) data
+     * connection successfully.
+     */
+    bool preferred;
+
+    /**
+     * If true, modem must persist this data profile and profileId must not be
+     * set to DataProfileId.INVALID. If the same data profile exists, this data profile must
+     * overwrite it.
+     */
+    bool persistent;
+};
+
+struct CardStatus {
+    @1.2::CardStatus base;
+    /**
+     * The EID is the eUICC identifier. The EID shall be stored within the ECASD and can be
+     * retrieved by the Device at any time using the standard GlobalPlatform GET DATA command.
+     *
+     * This data is mandatory and applicable only when cardState is CardState:PRESENT and SIM card
+     * supports eUICC.
+     */
+    string eid;
+};
diff --git a/radio/config/1.0/vts/functional/Android.bp b/radio/config/1.0/vts/functional/Android.bp
index aa8266e..9c96030 100644
--- a/radio/config/1.0/vts/functional/Android.bp
+++ b/radio/config/1.0/vts/functional/Android.bp
@@ -29,4 +29,5 @@
         "android.hardware.radio.config@1.0",
     ],
     header_libs: ["radio.util.header@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/radio/config/1.1/Android.bp b/radio/config/1.1/Android.bp
new file mode 100644
index 0000000..056510c
--- /dev/null
+++ b/radio/config/1.1/Android.bp
@@ -0,0 +1,26 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.radio.config@1.1",
+    root: "android.hardware",
+    vndk: {
+        enabled: true,
+    },
+    srcs: [
+        "IRadioConfig.hal",
+        "IRadioConfigIndication.hal",
+        "IRadioConfigResponse.hal",
+        "types.hal",
+    ],
+    interfaces: [
+        "android.hardware.radio.config@1.0",
+        "android.hardware.radio@1.0",
+        "android.hidl.base@1.0",
+    ],
+    types: [
+        "ModemInfo",
+        "PhoneCapability",
+    ],
+    gen_java: true,
+}
+
diff --git a/radio/config/1.1/IRadioConfig.hal b/radio/config/1.1/IRadioConfig.hal
new file mode 100644
index 0000000..bc63339
--- /dev/null
+++ b/radio/config/1.1/IRadioConfig.hal
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.radio.config@1.1;
+
+import @1.0::IRadioConfig;
+import @1.1::IRadioConfigResponse;
+import @1.1::PhoneCapability;
+
+/**
+ * Note: IRadioConfig 1.1 is an intermediate layer between Android P and Android Q.
+ * It's specifically designed for CBRS related interfaces. All other interfaces
+ * for Q are added in IRadioConfig 1.2.
+ *
+ * This interface is used by telephony and telecom to talk to cellular radio for the purpose of
+ * radio configuration, and it is not associated with any specific modem or slot.
+ * All the functions have minimum one parameter:
+ * serial: which corresponds to serial no. of request. Serial numbers must only be memorized for the
+ * duration of a method call. If clients provide colliding serials (including passing the same
+ * serial to different methods), multiple responses (one for each method call) must still be served.
+ */
+interface IRadioConfig extends @1.0::IRadioConfig {
+   /**
+     * Request current phone capability.
+     *
+     * @param serial Serial number of request.
+     *
+     * Response callback is IRadioResponse.getPhoneCapabilityResponse() which
+     * will return <@1.1::PhoneCapability>.
+     */
+    oneway getPhoneCapability(int32_t serial);
+
+   /**
+     * Set preferred data modem Id.
+     * In a multi-SIM device, notify modem layer which logical modem will be used primarily
+     * for data. It helps modem with resource optimization and decisions of what data connections
+     * should be satisfied.
+     *
+     * @param serial Serial number of request.
+     * @param modem Id the logical modem ID, which should match one of modem IDs returned
+     * from getPhoneCapability().
+     *
+     * Response callback is IRadioConfigResponse.setPreferredDataModemResponse()
+     */
+    oneway setPreferredDataModem(int32_t serial, uint8_t modemId);
+};
diff --git a/audio/effect/4.0/default/NoiseSuppressionEffect.cpp b/radio/config/1.1/IRadioConfigIndication.hal
similarity index 72%
rename from audio/effect/4.0/default/NoiseSuppressionEffect.cpp
rename to radio/config/1.1/IRadioConfigIndication.hal
index e83a8e3..f919201 100644
--- a/audio/effect/4.0/default/NoiseSuppressionEffect.cpp
+++ b/radio/config/1.1/IRadioConfigIndication.hal
@@ -14,10 +14,12 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "NS_Effect_HAL"
+package android.hardware.radio.config@1.1;
 
-#include "NoiseSuppressionEffect.h"
+import @1.0::IRadioConfigIndication;
 
-#define AUDIO_HAL_VERSION V4_0
-#include <effect/all-versions/default/NoiseSuppressionEffect.impl.h>
-#undef AUDIO_HAL_VERSION
+/**
+ * Interface declaring unsolicited radio config indications.
+ */
+interface IRadioConfigIndication extends @1.0::IRadioConfigIndication {
+};
diff --git a/radio/config/1.1/IRadioConfigResponse.hal b/radio/config/1.1/IRadioConfigResponse.hal
new file mode 100644
index 0000000..42a31b1
--- /dev/null
+++ b/radio/config/1.1/IRadioConfigResponse.hal
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.radio.config@1.1;
+
+import @1.0::IRadioConfigResponse;
+import @1.1::PhoneCapability;
+import android.hardware.radio@1.0::RadioResponseInfo;
+
+/**
+ * Note: IRadioConfig 1.1 is an intermediate layer between Android P and Android Q.
+ * It's specifically designed for CBRS related interfaces. All other interfaces
+ * for Q are be added in IRadioConfig 1.2.
+ *
+ * Interface declaring response functions to solicited radio config requests.
+ */
+interface IRadioConfigResponse extends @1.0::IRadioConfigResponse {
+    /**
+     * @param info Response info struct containing response type, serial no. and error
+     * @param phoneCapability <@1.1::PhoneCapability> it defines modem's capability for example
+     *        how many logical modems it has, how many data connections it supports.
+     *
+     * Valid errors returned:
+     *   RadioError:NONE
+     *   RadioError:RADIO_NOT_AVAILABLE
+     *   RadioError:INTERNAL_ERR
+     */
+    oneway getPhoneCapabilityResponse(RadioResponseInfo info, PhoneCapability phoneCapability);
+
+    /**
+     * @param info Response info struct containing response type, serial no. and error
+     *
+     * Valid errors returned:
+     *   RadioError:NONE
+     *   RadioError:RADIO_NOT_AVAILABLE
+     *   RadioError:INTERNAL_ERR
+     *   RadioError:INVALID_ARGUMENTS
+     */
+    oneway setPreferredDataModemResponse(RadioResponseInfo info);
+};
diff --git a/radio/config/1.1/types.hal b/radio/config/1.1/types.hal
new file mode 100644
index 0000000..a7b9f86
--- /dev/null
+++ b/radio/config/1.1/types.hal
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.radio.config@1.1;
+
+/**
+ * Note: IRadioConfig 1.1 is an intermediate layer between Android P and Android Q.
+ * It's specifically designed for CBRS related interfaces. All other interfaces
+ * for Q are be added in IRadioConfig 1.2.
+ */
+
+/**
+ * A field in PhoneCapability that has information of each logical modem.
+ */
+struct ModemInfo {
+    /**
+     * Logical modem ID.
+     */
+    uint8_t modemId;
+};
+
+/**
+ * Phone capability which describes the data connection capability of modem.
+ * It's used to evaluate possible phone config change, for example from single
+ * SIM device to multi-SIM device.
+ */
+struct PhoneCapability {
+    /**
+     * maxActiveData defines how many logical modems can have
+     * PS attached simultaneously. For example, for L+L modem it
+     * should be 2.
+     */
+    uint8_t maxActiveData;
+    /**
+     * maxActiveData defines how many logical modems can have
+     * internet PDN connections simultaneously. For example, for L+L
+     * DSDS modem it’s 1, and for DSDA modem it’s 2.
+     */
+    uint8_t maxActiveInternetData;
+    /**
+     * Whether modem supports both internet PDN up so
+     * that we can do ping test before tearing down the
+     * other one.
+     */
+    bool isInternetLingeringSupported;
+    /**
+     * List of logical modem information.
+     */
+    vec<ModemInfo> logicalModemList;
+};
diff --git a/radio/config/1.2/Android.bp b/radio/config/1.2/Android.bp
new file mode 100644
index 0000000..3e6a425
--- /dev/null
+++ b/radio/config/1.2/Android.bp
@@ -0,0 +1,25 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.radio.config@1.2",
+    root: "android.hardware",
+    vndk: {
+        enabled: true,
+    },
+    srcs: [
+        "types.hal",
+        "IRadioConfigIndication.hal",
+        "IRadioConfigResponse.hal",
+    ],
+    interfaces: [
+        "android.hardware.radio.config@1.0",
+        "android.hardware.radio.config@1.1",
+        "android.hardware.radio@1.0",
+        "android.hidl.base@1.0",
+    ],
+    types: [
+        "SimSlotStatus",
+    ],
+    gen_java: true,
+}
+
diff --git a/radio/config/1.2/IRadioConfigIndication.hal b/radio/config/1.2/IRadioConfigIndication.hal
new file mode 100644
index 0000000..a3ae558
--- /dev/null
+++ b/radio/config/1.2/IRadioConfigIndication.hal
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.radio.config@1.2;
+
+import android.hardware.radio@1.0::RadioIndicationType;
+import @1.1::IRadioConfigIndication;
+
+/**
+ * Interface declaring unsolicited radio config indications.
+ */
+interface IRadioConfigIndication extends @1.1::IRadioConfigIndication {
+
+    /**
+     * Indicates SIM slot status change.
+     *
+     * This indication must be sent by the modem whenever there is any slot status change, even the
+     * slot is inactive. For example, this indication must be triggered if a SIM card is inserted
+     * into an inactive slot.
+     *
+     * @param type Type of radio indication
+     * @param slotStatus new slot status info with size equals to the number of physical slots on
+     *        the device
+     */
+    oneway simSlotsStatusChanged_1_2(RadioIndicationType type, vec<SimSlotStatus> slotStatus);
+};
\ No newline at end of file
diff --git a/radio/config/1.2/IRadioConfigResponse.hal b/radio/config/1.2/IRadioConfigResponse.hal
new file mode 100644
index 0000000..dbc3bc5
--- /dev/null
+++ b/radio/config/1.2/IRadioConfigResponse.hal
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.radio.config@1.2;
+
+import android.hardware.radio@1.0::RadioResponseInfo;
+import @1.1::IRadioConfigResponse;
+import @1.2::SimSlotStatus;
+
+/**
+ * Interface declaring response functions to solicited radio config requests.
+ */
+interface IRadioConfigResponse extends @1.1::IRadioConfigResponse {
+
+    /**
+     * @param info Response info struct containing response type, serial no. and error
+     * @param slotStatus Sim slot struct containing all the physical SIM slots info with size
+     *        equal to the number of physical slots on the device
+     *
+     * Valid errors returned:
+     *   RadioError:NONE
+     *   RadioError:RADIO_NOT_AVAILABLE
+     *   RadioError:NO_MEMORY
+     *   RadioError:INTERNAL_ERR
+     *   RadioError:MODEM_ERR
+     */
+    oneway getSimSlotsStatusResponse_1_2(RadioResponseInfo info, vec<SimSlotStatus> slotStatus);
+};
\ No newline at end of file
diff --git a/radio/config/1.2/types.hal b/radio/config/1.2/types.hal
new file mode 100644
index 0000000..5b809a7
--- /dev/null
+++ b/radio/config/1.2/types.hal
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.radio.config@1.2;
+
+import android.hardware.radio@1.0::CardState;
+import @1.0::SimSlotStatus;
+
+struct SimSlotStatus {
+    @1.0::SimSlotStatus base;
+    /**
+     * The EID is the eUICC identifier. The EID shall be stored within the ECASD and can be
+     * retrieved by the Device at any time using the standard GlobalPlatform GET DATA command.
+     *
+     * This data is mandatory and applicable only when cardState is CardState:PRESENT and SIM card
+     * supports eUICC.
+     */
+    string eid;
+};
\ No newline at end of file
diff --git a/renderscript/1.0/default/Context.cpp b/renderscript/1.0/default/Context.cpp
index f5b70c9..bb2a40e 100644
--- a/renderscript/1.0/default/Context.cpp
+++ b/renderscript/1.0/default/Context.cpp
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2018 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 "Context.h"
 #include "Device.h"
 
diff --git a/renderscript/1.0/default/Context.h b/renderscript/1.0/default/Context.h
index d8bfe4f..4ed2d9a 100644
--- a/renderscript/1.0/default/Context.h
+++ b/renderscript/1.0/default/Context.h
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 #ifndef ANDROID_HARDWARE_RENDERSCRIPT_V1_0_CONTEXT_H
 #define ANDROID_HARDWARE_RENDERSCRIPT_V1_0_CONTEXT_H
 
diff --git a/renderscript/1.0/default/Device.cpp b/renderscript/1.0/default/Device.cpp
index 8fda3ff..d603a12 100644
--- a/renderscript/1.0/default/Device.cpp
+++ b/renderscript/1.0/default/Device.cpp
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2018 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 "Context.h"
 #include "Device.h"
 
diff --git a/renderscript/1.0/default/Device.h b/renderscript/1.0/default/Device.h
index f5bda37..74e1907 100644
--- a/renderscript/1.0/default/Device.h
+++ b/renderscript/1.0/default/Device.h
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 #ifndef ANDROID_HARDWARE_RENDERSCRIPT_V1_0_DEVICE_H
 #define ANDROID_HARDWARE_RENDERSCRIPT_V1_0_DEVICE_H
 
diff --git a/renderscript/1.0/vts/functional/Android.bp b/renderscript/1.0/vts/functional/Android.bp
index bf011e6..87e62f1 100644
--- a/renderscript/1.0/vts/functional/Android.bp
+++ b/renderscript/1.0/vts/functional/Android.bp
@@ -28,4 +28,5 @@
         "android.hardware.renderscript@1.0",
         "libnativewindow",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/secure_element/1.0/vts/functional/Android.bp b/secure_element/1.0/vts/functional/Android.bp
index 752df9e..2b2b73e 100644
--- a/secure_element/1.0/vts/functional/Android.bp
+++ b/secure_element/1.0/vts/functional/Android.bp
@@ -21,4 +21,5 @@
     static_libs: [
         "android.hardware.secure_element@1.0",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/sensors/1.0/vts/functional/Android.bp b/sensors/1.0/vts/functional/Android.bp
index 6563e3c..d4c5f32 100644
--- a/sensors/1.0/vts/functional/Android.bp
+++ b/sensors/1.0/vts/functional/Android.bp
@@ -27,5 +27,6 @@
         "android.hardware.sensors@1.0",
         "VtsHalSensorsTargetTestUtils",
     ],
+    test_suites: ["general-tests"],
 }
 
diff --git a/sensors/2.0/default/Android.bp b/sensors/2.0/default/Android.bp
index 11612d3..db0b148 100644
--- a/sensors/2.0/default/Android.bp
+++ b/sensors/2.0/default/Android.bp
@@ -32,6 +32,7 @@
         "libhidlbase",
         "libhidltransport",
         "liblog",
+        "libpower",
         "libutils",
     ],
 }
diff --git a/sensors/2.0/default/Sensor.cpp b/sensors/2.0/default/Sensor.cpp
index d3e3f7e..168b402 100644
--- a/sensors/2.0/default/Sensor.cpp
+++ b/sensors/2.0/default/Sensor.cpp
@@ -29,14 +29,20 @@
 using ::android::hardware::sensors::V1_0::SensorStatus;
 
 Sensor::Sensor(ISensorsEventCallback* callback)
-    : mIsEnabled(false), mSamplingPeriodNs(0), mLastSampleTimeNs(0), mCallback(callback) {
+    : mIsEnabled(false),
+      mSamplingPeriodNs(0),
+      mLastSampleTimeNs(0),
+      mCallback(callback),
+      mMode(OperationMode::NORMAL) {
     mRunThread = std::thread(startThread, this);
 }
 
 Sensor::~Sensor() {
+    std::unique_lock<std::mutex> lock(mRunMutex);
     mStopThread = true;
     mIsEnabled = false;
     mWaitCV.notify_all();
+    lock.release();
     mRunThread.join();
 }
 
@@ -60,6 +66,7 @@
 
 void Sensor::activate(bool enable) {
     if (mIsEnabled != enable) {
+        std::unique_lock<std::mutex> lock(mRunMutex);
         mIsEnabled = enable;
         mWaitCV.notify_all();
     }
@@ -79,7 +86,7 @@
     ev.sensorType = SensorType::ADDITIONAL_INFO;
     ev.u.meta.what = MetaDataEventType::META_DATA_FLUSH_COMPLETE;
     std::vector<Event> evs{ev};
-    mCallback->postEvents(evs);
+    mCallback->postEvents(evs, isWakeUpSensor());
 
     return Result::OK;
 }
@@ -89,13 +96,14 @@
 }
 
 void Sensor::run() {
-    std::mutex runMutex;
-    std::unique_lock<std::mutex> runLock(runMutex);
+    std::unique_lock<std::mutex> runLock(mRunMutex);
     constexpr int64_t kNanosecondsInSeconds = 1000 * 1000 * 1000;
 
     while (!mStopThread) {
-        if (!mIsEnabled) {
-            mWaitCV.wait(runLock, [&] { return mIsEnabled || mStopThread; });
+        if (!mIsEnabled || mMode == OperationMode::DATA_INJECTION) {
+            mWaitCV.wait(runLock, [&] {
+                return ((mIsEnabled && mMode == OperationMode::NORMAL) || mStopThread);
+            });
         } else {
             timespec curTime;
             clock_gettime(CLOCK_REALTIME, &curTime);
@@ -105,7 +113,7 @@
             if (now >= nextSampleTime) {
                 mLastSampleTimeNs = now;
                 nextSampleTime = mLastSampleTimeNs + mSamplingPeriodNs;
-                mCallback->postEvents(readEvents());
+                mCallback->postEvents(readEvents(), isWakeUpSensor());
             }
 
             mWaitCV.wait_for(runLock, std::chrono::nanoseconds(nextSampleTime - now));
@@ -113,6 +121,10 @@
     }
 }
 
+bool Sensor::isWakeUpSensor() {
+    return mSensorInfo.flags & static_cast<uint32_t>(SensorFlagBits::WAKE_UP);
+}
+
 std::vector<Event> Sensor::readEvents() {
     std::vector<Event> events;
     Event event;
@@ -127,6 +139,33 @@
     return events;
 }
 
+void Sensor::setOperationMode(OperationMode mode) {
+    if (mMode != mode) {
+        std::unique_lock<std::mutex> lock(mRunMutex);
+        mMode = mode;
+        mWaitCV.notify_all();
+    }
+}
+
+bool Sensor::supportsDataInjection() const {
+    return mSensorInfo.flags & static_cast<uint32_t>(SensorFlagBits::DATA_INJECTION);
+}
+
+Result Sensor::injectEvent(const Event& event) {
+    Result result = Result::OK;
+    if (event.sensorType == SensorType::ADDITIONAL_INFO) {
+        // When in OperationMode::NORMAL, SensorType::ADDITIONAL_INFO is used to push operation
+        // environment data into the device.
+    } else if (!supportsDataInjection()) {
+        result = Result::INVALID_OPERATION;
+    } else if (mMode == OperationMode::DATA_INJECTION) {
+        mCallback->postEvents(std::vector<Event>{event}, isWakeUpSensor());
+    } else {
+        result = Result::BAD_VALUE;
+    }
+    return result;
+}
+
 AccelSensor::AccelSensor(int32_t sensorHandle, ISensorsEventCallback* callback) : Sensor(callback) {
     mSensorInfo.sensorHandle = sensorHandle;
     mSensorInfo.name = "Accel Sensor";
@@ -142,7 +181,8 @@
     mSensorInfo.fifoReservedEventCount = 0;
     mSensorInfo.fifoMaxEventCount = 0;
     mSensorInfo.requiredPermission = "";
-    mSensorInfo.flags = static_cast<uint32_t>(SensorFlagBits::WAKE_UP);
+    mSensorInfo.flags =
+        static_cast<uint32_t>(SensorFlagBits::WAKE_UP | SensorFlagBits::DATA_INJECTION);
 };
 
 }  // namespace implementation
diff --git a/sensors/2.0/default/Sensor.h b/sensors/2.0/default/Sensor.h
index 75d9aab..3ab2299 100644
--- a/sensors/2.0/default/Sensor.h
+++ b/sensors/2.0/default/Sensor.h
@@ -21,10 +21,12 @@
 
 #include <condition_variable>
 #include <memory>
+#include <mutex>
 #include <thread>
 #include <vector>
 
 using ::android::hardware::sensors::V1_0::Event;
+using ::android::hardware::sensors::V1_0::OperationMode;
 using ::android::hardware::sensors::V1_0::Result;
 using ::android::hardware::sensors::V1_0::SensorInfo;
 using ::android::hardware::sensors::V1_0::SensorType;
@@ -38,7 +40,7 @@
 class ISensorsEventCallback {
    public:
     virtual ~ISensorsEventCallback(){};
-    virtual void postEvents(const std::vector<Event>& events) = 0;
+    virtual void postEvents(const std::vector<Event>& events, bool wakeup) = 0;
 };
 
 class Sensor {
@@ -51,11 +53,17 @@
     void activate(bool enable);
     Result flush();
 
+    void setOperationMode(OperationMode mode);
+    bool supportsDataInjection() const;
+    Result injectEvent(const Event& event);
+
    protected:
     void run();
     virtual std::vector<Event> readEvents();
     static void startThread(Sensor* sensor);
 
+    bool isWakeUpSensor();
+
     bool mIsEnabled;
     int64_t mSamplingPeriodNs;
     int64_t mLastSampleTimeNs;
@@ -63,9 +71,12 @@
 
     std::atomic_bool mStopThread;
     std::condition_variable mWaitCV;
+    std::mutex mRunMutex;
     std::thread mRunThread;
 
     ISensorsEventCallback* mCallback;
+
+    OperationMode mMode;
 };
 
 class AccelSensor : public Sensor {
diff --git a/sensors/2.0/default/Sensors.cpp b/sensors/2.0/default/Sensors.cpp
index cceb7d5..efc8b05 100644
--- a/sensors/2.0/default/Sensors.cpp
+++ b/sensors/2.0/default/Sensors.cpp
@@ -30,8 +30,16 @@
 using ::android::hardware::sensors::V1_0::RateLevel;
 using ::android::hardware::sensors::V1_0::Result;
 using ::android::hardware::sensors::V1_0::SharedMemInfo;
+using ::android::hardware::sensors::V2_0::SensorTimeout;
 
-Sensors::Sensors() : mEventQueueFlag(nullptr) {
+constexpr const char* kWakeLockName = "SensorsHAL_WAKEUP";
+
+Sensors::Sensors()
+    : mEventQueueFlag(nullptr),
+      mOutstandingWakeUpEvents(0),
+      mReadWakeLockQueueRun(false),
+      mAutoReleaseWakeLockTime(0),
+      mHasWakeLock(false) {
     std::shared_ptr<AccelSensor> accel =
         std::make_shared<AccelSensor>(1 /* sensorHandle */, this /* callback */);
     mSensors[accel->getSensorInfo().sensorHandle] = accel;
@@ -39,6 +47,8 @@
 
 Sensors::~Sensors() {
     deleteEventFlag();
+    mReadWakeLockQueueRun = false;
+    mWakeLockThread.join();
 }
 
 // Methods from ::android::hardware::sensors::V2_0::ISensors follow.
@@ -54,9 +64,11 @@
     return Void();
 }
 
-Return<Result> Sensors::setOperationMode(OperationMode /* mode */) {
-    // TODO implement
-    return Result{};
+Return<Result> Sensors::setOperationMode(OperationMode mode) {
+    for (auto sensor : mSensors) {
+        sensor.second->setOperationMode(mode);
+    }
+    return Result::OK;
 }
 
 Return<Result> Sensors::activate(int32_t sensorHandle, bool enabled) {
@@ -99,6 +111,10 @@
         result = Result::BAD_VALUE;
     }
 
+    // Start the thread to read events from the Wake Lock FMQ
+    mReadWakeLockQueueRun = true;
+    mWakeLockThread = std::thread(startReadWakeLockThread, this);
+
     return result;
 }
 
@@ -120,14 +136,18 @@
     return Result::BAD_VALUE;
 }
 
-Return<Result> Sensors::injectSensorData(const Event& /* event */) {
-    // TODO implement
-    return Result{};
+Return<Result> Sensors::injectSensorData(const Event& event) {
+    auto sensor = mSensors.find(event.sensorHandle);
+    if (sensor != mSensors.end()) {
+        return sensor->second->injectEvent(event);
+    }
+
+    return Result::BAD_VALUE;
 }
 
 Return<void> Sensors::registerDirectChannel(const SharedMemInfo& /* mem */,
                                             registerDirectChannel_cb _hidl_cb) {
-    _hidl_cb(Result::INVALID_OPERATION, 0 /* channelHandle */);
+    _hidl_cb(Result::INVALID_OPERATION, -1 /* channelHandle */);
     return Return<void>();
 }
 
@@ -141,15 +161,67 @@
     return Return<void>();
 }
 
-void Sensors::postEvents(const std::vector<Event>& events) {
-    std::lock_guard<std::mutex> l(mLock);
+void Sensors::postEvents(const std::vector<Event>& events, bool wakeup) {
+    std::lock_guard<std::mutex> lock(mWriteLock);
+    if (mEventQueue->write(events.data(), events.size())) {
+        mEventQueueFlag->wake(static_cast<uint32_t>(EventQueueFlagBits::READ_AND_PROCESS));
 
-    // TODO: read events from the Wake Lock FMQ in the right place
-    std::vector<uint32_t> tmp(mWakeLockQueue->availableToRead());
-    mWakeLockQueue->read(tmp.data(), mWakeLockQueue->availableToRead());
+        if (wakeup) {
+            // Keep track of the number of outstanding WAKE_UP events in order to properly hold
+            // a wake lock until the framework has secured a wake lock
+            updateWakeLock(events.size(), 0 /* eventsHandled */);
+        }
+    }
+}
 
-    mEventQueue->write(events.data(), events.size());
-    mEventQueueFlag->wake(static_cast<uint32_t>(EventQueueFlagBits::READ_AND_PROCESS));
+void Sensors::updateWakeLock(int32_t eventsWritten, int32_t eventsHandled) {
+    std::lock_guard<std::mutex> lock(mWakeLockLock);
+    int32_t newVal = mOutstandingWakeUpEvents + eventsWritten - eventsHandled;
+    if (newVal < 0) {
+        mOutstandingWakeUpEvents = 0;
+    } else {
+        mOutstandingWakeUpEvents = newVal;
+    }
+
+    if (eventsWritten > 0) {
+        // Update the time at which the last WAKE_UP event was sent
+        mAutoReleaseWakeLockTime = ::android::uptimeMillis() +
+                                   static_cast<uint32_t>(SensorTimeout::WAKE_LOCK_SECONDS) * 1000;
+    }
+
+    if (!mHasWakeLock && mOutstandingWakeUpEvents > 0 &&
+        acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLockName) == 0) {
+        mHasWakeLock = true;
+    } else if (mHasWakeLock) {
+        // Check if the wake lock should be released automatically if
+        // SensorTimeout::WAKE_LOCK_SECONDS has elapsed since the last WAKE_UP event was written to
+        // the Wake Lock FMQ.
+        if (::android::uptimeMillis() > mAutoReleaseWakeLockTime) {
+            ALOGD("No events read from wake lock FMQ for %d seconds, auto releasing wake lock",
+                  SensorTimeout::WAKE_LOCK_SECONDS);
+            mOutstandingWakeUpEvents = 0;
+        }
+
+        if (mOutstandingWakeUpEvents == 0 && release_wake_lock(kWakeLockName) == 0) {
+            mHasWakeLock = false;
+        }
+    }
+}
+
+void Sensors::readWakeLockFMQ() {
+    while (mReadWakeLockQueueRun.load()) {
+        constexpr int64_t kReadTimeoutNs = 500 * 1000 * 1000;  // 500 ms
+        uint32_t eventsHandled = 0;
+
+        // Read events from the Wake Lock FMQ. Timeout after a reasonable amount of time to ensure
+        // that any held wake lock is able to be released if it is held for too long.
+        mWakeLockQueue->readBlocking(&eventsHandled, 1 /* count */, kReadTimeoutNs);
+        updateWakeLock(0 /* eventsWritten */, eventsHandled);
+    }
+}
+
+void Sensors::startReadWakeLockThread(Sensors* sensors) {
+    sensors->readWakeLockFMQ();
 }
 
 void Sensors::deleteEventFlag() {
diff --git a/sensors/2.0/default/Sensors.h b/sensors/2.0/default/Sensors.h
index f543935..eba3f97 100644
--- a/sensors/2.0/default/Sensors.h
+++ b/sensors/2.0/default/Sensors.h
@@ -21,10 +21,13 @@
 
 #include <android/hardware/sensors/2.0/ISensors.h>
 #include <fmq/MessageQueue.h>
+#include <hardware_legacy/power.h>
 #include <hidl/MQDescriptor.h>
 #include <hidl/Status.h>
 
+#include <atomic>
 #include <memory>
+#include <thread>
 
 namespace android {
 namespace hardware {
@@ -80,7 +83,7 @@
     Return<void> configDirectReport(int32_t sensorHandle, int32_t channelHandle, RateLevel rate,
                                     configDirectReport_cb _hidl_cb) override;
 
-    void postEvents(const std::vector<Event>& events) override;
+    void postEvents(const std::vector<Event>& events, bool wakeup) override;
 
    private:
     /**
@@ -88,6 +91,18 @@
      */
     void deleteEventFlag();
 
+    /**
+     * Function to read the Wake Lock FMQ and release the wake lock when appropriate
+     */
+    void readWakeLockFMQ();
+
+    static void startReadWakeLockThread(Sensors* sensors);
+
+    /**
+     * Responsible for acquiring and releasing a wake lock when there are unhandled WAKE_UP events
+     */
+    void updateWakeLock(int32_t eventsWritten, int32_t eventsHandled);
+
     using EventMessageQueue = MessageQueue<Event, kSynchronizedReadWrite>;
     using WakeLockMessageQueue = MessageQueue<uint32_t, kSynchronizedReadWrite>;
 
@@ -117,9 +132,39 @@
     std::map<int32_t, std::shared_ptr<Sensor>> mSensors;
 
     /**
-     * Lock to protect writes and reads to the FMQs
+     * Lock to protect writes to the FMQs
      */
-    std::mutex mLock;
+    std::mutex mWriteLock;
+
+    /**
+     * Lock to protect acquiring and releasing the wake lock
+     */
+    std::mutex mWakeLockLock;
+
+    /**
+     * Track the number of WAKE_UP events that have not been handled by the framework
+     */
+    uint32_t mOutstandingWakeUpEvents;
+
+    /**
+     * A thread to read the Wake Lock FMQ
+     */
+    std::thread mWakeLockThread;
+
+    /**
+     * Flag to indicate that the Wake Lock Thread should continue to run
+     */
+    std::atomic_bool mReadWakeLockQueueRun;
+
+    /**
+     * Track the time when the wake lock should automatically be released
+     */
+    int64_t mAutoReleaseWakeLockTime;
+
+    /**
+     * Flag to indicate if a wake lock has been acquired
+     */
+    bool mHasWakeLock;
 };
 
 }  // namespace implementation
diff --git a/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp b/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp
index 3e5837b..ac020ad 100644
--- a/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp
+++ b/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp
@@ -18,6 +18,7 @@
 
 #include "SensorsHidlEnvironmentV2_0.h"
 #include "sensors-vts-utils/SensorsHidlTestBase.h"
+#include "sensors-vts-utils/SensorsTestSharedMemory.h"
 
 #include <android/hardware/sensors/2.0/ISensors.h>
 #include <android/hardware/sensors/2.0/types.h>
@@ -26,6 +27,7 @@
 
 #include <cinttypes>
 #include <condition_variable>
+#include <cstring>
 #include <map>
 #include <vector>
 
@@ -34,7 +36,9 @@
 using ::android::hardware::Void;
 using ::android::hardware::sensors::V1_0::MetaDataEventType;
 using ::android::hardware::sensors::V1_0::OperationMode;
+using ::android::hardware::sensors::V1_0::SensorsEventFormatOffset;
 using ::android::hardware::sensors::V1_0::SensorStatus;
+using ::android::hardware::sensors::V1_0::SharedMemType;
 using ::android::hardware::sensors::V1_0::Vec3;
 
 class EventCallback : public IEventCallback {
@@ -164,7 +168,17 @@
     void activateAllSensors(bool enable);
     std::vector<SensorInfo> getNonOneShotSensors();
     std::vector<SensorInfo> getOneShotSensors();
+    std::vector<SensorInfo> getInjectEventSensors();
     int32_t getInvalidSensorHandle();
+    void verifyDirectChannel(SharedMemType memType);
+    void verifyRegisterDirectChannel(const SensorInfo& sensor, SharedMemType memType,
+                                     std::shared_ptr<SensorsTestSharedMemory> mem,
+                                     int32_t* directChannelHandle);
+    void verifyConfigure(const SensorInfo& sensor, SharedMemType memType,
+                         int32_t directChannelHandle);
+    void verifyUnregisterDirectChannel(const SensorInfo& sensor, SharedMemType memType,
+                                       int32_t directChannelHandle);
+    void checkRateLevel(const SensorInfo& sensor, int32_t directChannelHandle, RateLevel rateLevel);
 };
 
 Return<Result> SensorsHidlTest::activate(int32_t sensorHandle, bool enabled) {
@@ -243,6 +257,16 @@
     return sensors;
 }
 
+std::vector<SensorInfo> SensorsHidlTest::getInjectEventSensors() {
+    std::vector<SensorInfo> sensors;
+    for (const SensorInfo& info : getSensorsList()) {
+        if (info.flags & static_cast<uint32_t>(SensorFlagBits::DATA_INJECTION)) {
+            sensors.push_back(info);
+        }
+    }
+    return sensors;
+}
+
 int32_t SensorsHidlTest::getInvalidSensorHandle() {
     // Find a sensor handle that does not exist in the sensor list
     int32_t maxHandle = 0;
@@ -297,63 +321,71 @@
     });
 }
 
-// Test if sensor list returned is valid
+// Test that SetOperationMode returns the expected value
 TEST_F(SensorsHidlTest, SetOperationMode) {
-    std::vector<SensorInfo> sensorList = getSensorsList();
-
-    bool needOperationModeSupport =
-        std::any_of(sensorList.begin(), sensorList.end(),
-                    [](const auto& s) { return (s.flags & SensorFlagBits::DATA_INJECTION) != 0; });
-    if (!needOperationModeSupport) {
-        return;
+    std::vector<SensorInfo> sensors = getInjectEventSensors();
+    if (getInjectEventSensors().size() > 0) {
+        ASSERT_EQ(Result::OK, getSensors()->setOperationMode(OperationMode::NORMAL));
+        ASSERT_EQ(Result::OK, getSensors()->setOperationMode(OperationMode::DATA_INJECTION));
+        ASSERT_EQ(Result::OK, getSensors()->setOperationMode(OperationMode::NORMAL));
+    } else {
+        ASSERT_EQ(Result::BAD_VALUE, getSensors()->setOperationMode(OperationMode::DATA_INJECTION));
     }
-
-    ASSERT_EQ(Result::OK, getSensors()->setOperationMode(OperationMode::NORMAL));
-    ASSERT_EQ(Result::OK, getSensors()->setOperationMode(OperationMode::DATA_INJECTION));
-    ASSERT_EQ(Result::OK, getSensors()->setOperationMode(OperationMode::NORMAL));
 }
 
-// Test if sensor list returned is valid
+// Test that an injected event is written back to the Event FMQ
 TEST_F(SensorsHidlTest, InjectSensorEventData) {
-    std::vector<SensorInfo> sensorList = getSensorsList();
-    std::vector<SensorInfo> sensorSupportInjection;
-
-    bool needOperationModeSupport =
-        std::any_of(sensorList.begin(), sensorList.end(), [&sensorSupportInjection](const auto& s) {
-            bool ret = (s.flags & SensorFlagBits::DATA_INJECTION) != 0;
-            if (ret) {
-                sensorSupportInjection.push_back(s);
-            }
-            return ret;
-        });
-    if (!needOperationModeSupport) {
+    std::vector<SensorInfo> sensors = getInjectEventSensors();
+    if (sensors.size() == 0) {
         return;
     }
 
-    ASSERT_EQ(Result::OK, getSensors()->setOperationMode(OperationMode::NORMAL));
     ASSERT_EQ(Result::OK, getSensors()->setOperationMode(OperationMode::DATA_INJECTION));
 
-    for (const auto& s : sensorSupportInjection) {
-        switch (s.type) {
-            case SensorType::ACCELEROMETER:
-            case SensorType::GYROSCOPE:
-            case SensorType::MAGNETIC_FIELD: {
-                usleep(100000);  // sleep 100ms
+    EventCallback callback;
+    getEnvironment()->registerCallback(&callback);
 
-                Event dummy;
-                dummy.timestamp = android::elapsedRealtimeNano();
-                dummy.sensorType = s.type;
-                dummy.sensorHandle = s.sensorHandle;
-                Vec3 v = {1, 2, 3, SensorStatus::ACCURACY_HIGH};
-                dummy.u.vec3 = v;
+    // AdditionalInfo event should not be sent to Event FMQ
+    Event additionalInfoEvent;
+    additionalInfoEvent.sensorType = SensorType::ADDITIONAL_INFO;
+    additionalInfoEvent.timestamp = android::elapsedRealtimeNano();
 
-                EXPECT_EQ(Result::OK, getSensors()->injectSensorData(dummy));
-                break;
-            }
-            default:
-                break;
-        }
+    Event injectedEvent;
+    injectedEvent.timestamp = android::elapsedRealtimeNano();
+    Vec3 data = {1, 2, 3, SensorStatus::ACCURACY_HIGH};
+    injectedEvent.u.vec3 = data;
+
+    for (const auto& s : sensors) {
+        additionalInfoEvent.sensorHandle = s.sensorHandle;
+        EXPECT_EQ(Result::OK, getSensors()->injectSensorData(additionalInfoEvent));
+
+        injectedEvent.sensorType = s.type;
+        injectedEvent.sensorHandle = s.sensorHandle;
+        EXPECT_EQ(Result::OK, getSensors()->injectSensorData(injectedEvent));
     }
+
+    // Wait for events to be written back to the Event FMQ
+    callback.waitForEvents(sensors, 1000 /* timeoutMs */);
+
+    for (const auto& s : sensors) {
+        auto events = callback.getEvents(s.sensorHandle);
+        auto lastEvent = events.back();
+
+        // Verify that only a single event has been received
+        ASSERT_EQ(events.size(), 1);
+
+        // Verify that the event received matches the event injected and is not the additional
+        // info event
+        ASSERT_EQ(lastEvent.sensorType, s.type);
+        ASSERT_EQ(lastEvent.sensorType, s.type);
+        ASSERT_EQ(lastEvent.timestamp, injectedEvent.timestamp);
+        ASSERT_EQ(lastEvent.u.vec3.x, injectedEvent.u.vec3.x);
+        ASSERT_EQ(lastEvent.u.vec3.y, injectedEvent.u.vec3.y);
+        ASSERT_EQ(lastEvent.u.vec3.z, injectedEvent.u.vec3.z);
+        ASSERT_EQ(lastEvent.u.vec3.status, injectedEvent.u.vec3.status);
+    }
+
+    getEnvironment()->unregisterCallback();
     ASSERT_EQ(Result::OK, getSensors()->setOperationMode(OperationMode::NORMAL));
 }
 
@@ -789,6 +821,128 @@
     getEnvironment()->unregisterCallback();
 }
 
+void SensorsHidlTest::checkRateLevel(const SensorInfo& sensor, int32_t directChannelHandle,
+                                     RateLevel rateLevel) {
+    configDirectReport(sensor.sensorHandle, directChannelHandle, rateLevel,
+                       [&](Result result, int32_t reportToken) {
+                           if (isDirectReportRateSupported(sensor, rateLevel)) {
+                               ASSERT_EQ(result, Result::OK);
+                               ASSERT_GT(reportToken, 0);
+                           } else {
+                               ASSERT_EQ(result, Result::BAD_VALUE);
+                           }
+                       });
+}
+
+void SensorsHidlTest::verifyRegisterDirectChannel(const SensorInfo& sensor, SharedMemType memType,
+                                                  std::shared_ptr<SensorsTestSharedMemory> mem,
+                                                  int32_t* directChannelHandle) {
+    char* buffer = mem->getBuffer();
+    memset(buffer, 0xff, mem->getSize());
+
+    registerDirectChannel(mem->getSharedMemInfo(), [&](Result result, int32_t channelHandle) {
+        if (isDirectChannelTypeSupported(sensor, memType)) {
+            ASSERT_EQ(result, Result::OK);
+            ASSERT_GT(channelHandle, 0);
+
+            // Verify that the memory has been zeroed
+            for (size_t i = 0; i < mem->getSize(); i++) {
+                ASSERT_EQ(buffer[i], 0x00);
+            }
+        } else {
+            ASSERT_EQ(result, Result::INVALID_OPERATION);
+            ASSERT_EQ(channelHandle, -1);
+        }
+        *directChannelHandle = channelHandle;
+    });
+}
+
+void SensorsHidlTest::verifyConfigure(const SensorInfo& sensor, SharedMemType memType,
+                                      int32_t directChannelHandle) {
+    if (isDirectChannelTypeSupported(sensor, memType)) {
+        // Verify that each rate level is properly supported
+        checkRateLevel(sensor, directChannelHandle, RateLevel::NORMAL);
+        checkRateLevel(sensor, directChannelHandle, RateLevel::FAST);
+        checkRateLevel(sensor, directChannelHandle, RateLevel::VERY_FAST);
+        checkRateLevel(sensor, directChannelHandle, RateLevel::STOP);
+
+        // Verify that a sensor handle of -1 is only acceptable when using RateLevel::STOP
+        configDirectReport(
+            -1 /* sensorHandle */, directChannelHandle, RateLevel::NORMAL,
+            [](Result result, int32_t /* reportToken */) { ASSERT_EQ(result, Result::BAD_VALUE); });
+        configDirectReport(
+            -1 /* sensorHandle */, directChannelHandle, RateLevel::STOP,
+            [](Result result, int32_t /* reportToken */) { ASSERT_EQ(result, Result::OK); });
+    } else {
+        // Direct channel is not supported for this SharedMemType
+        configDirectReport(sensor.sensorHandle, directChannelHandle, RateLevel::NORMAL,
+                           [](Result result, int32_t /* reportToken */) {
+                               ASSERT_EQ(result, Result::INVALID_OPERATION);
+                           });
+    }
+}
+
+void SensorsHidlTest::verifyUnregisterDirectChannel(const SensorInfo& sensor, SharedMemType memType,
+                                                    int32_t directChannelHandle) {
+    Result result = unregisterDirectChannel(directChannelHandle);
+    if (isDirectChannelTypeSupported(sensor, memType)) {
+        ASSERT_EQ(result, Result::OK);
+    } else {
+        ASSERT_EQ(result, Result::INVALID_OPERATION);
+    }
+}
+
+void SensorsHidlTest::verifyDirectChannel(SharedMemType memType) {
+    constexpr size_t kEventSize = static_cast<size_t>(SensorsEventFormatOffset::TOTAL_LENGTH);
+    constexpr size_t kNumEvents = 1;
+    constexpr size_t kMemSize = kNumEvents * kEventSize;
+
+    std::shared_ptr<SensorsTestSharedMemory> mem(
+        SensorsTestSharedMemory::create(memType, kMemSize));
+    ASSERT_NE(mem, nullptr);
+
+    for (const SensorInfo& sensor : getSensorsList()) {
+        int32_t directChannelHandle = 0;
+        verifyRegisterDirectChannel(sensor, memType, mem, &directChannelHandle);
+        verifyConfigure(sensor, memType, directChannelHandle);
+        verifyUnregisterDirectChannel(sensor, memType, directChannelHandle);
+    }
+}
+
+TEST_F(SensorsHidlTest, DirectChannelAshmem) {
+    verifyDirectChannel(SharedMemType::ASHMEM);
+}
+
+TEST_F(SensorsHidlTest, DirectChannelGralloc) {
+    verifyDirectChannel(SharedMemType::GRALLOC);
+}
+
+TEST_F(SensorsHidlTest, ConfigureDirectChannelWithInvalidHandle) {
+    for (const SensorInfo& sensor : getSensorsList()) {
+        if (isDirectChannelTypeSupported(sensor, SharedMemType::ASHMEM) ||
+            isDirectChannelTypeSupported(sensor, SharedMemType::GRALLOC)) {
+            // Find a supported rate level
+            RateLevel rate = RateLevel::STOP;
+            if (isDirectReportRateSupported(sensor, RateLevel::NORMAL)) {
+                rate = RateLevel::NORMAL;
+            } else if (isDirectReportRateSupported(sensor, RateLevel::FAST)) {
+                rate = RateLevel::FAST;
+            } else if (isDirectReportRateSupported(sensor, RateLevel::VERY_FAST)) {
+                rate = RateLevel::VERY_FAST;
+            }
+
+            // Ensure that at least one rate level is supported
+            ASSERT_NE(rate, RateLevel::STOP);
+
+            // Verify that an invalid channel handle produces a BAD_VALUE result
+            configDirectReport(sensor.sensorHandle, -1, rate,
+                               [](Result result, int32_t /* reportToken */) {
+                                   ASSERT_EQ(result, Result::BAD_VALUE);
+                               });
+        }
+    }
+}
+
 int main(int argc, char** argv) {
     ::testing::AddGlobalTestEnvironment(SensorsHidlEnvironmentV2_0::Instance());
     ::testing::InitGoogleTest(&argc, argv);
diff --git a/sensors/common/vts/utils/SensorsTestSharedMemory.cpp b/sensors/common/vts/utils/SensorsTestSharedMemory.cpp
index 5096498..819e297 100644
--- a/sensors/common/vts/utils/SensorsTestSharedMemory.cpp
+++ b/sensors/common/vts/utils/SensorsTestSharedMemory.cpp
@@ -35,6 +35,10 @@
     return mBuffer;
 }
 
+size_t SensorsTestSharedMemory::getSize() const {
+    return mSize;
+}
+
 std::vector<Event> SensorsTestSharedMemory::parseEvents(int64_t lastCounter, size_t offset) const {
     constexpr size_t kEventSize = static_cast<size_t>(SensorsEventFormatOffset::TOTAL_LENGTH);
     constexpr size_t kOffsetSize = static_cast<size_t>(SensorsEventFormatOffset::SIZE_FIELD);
diff --git a/sensors/common/vts/utils/include/sensors-vts-utils/SensorsTestSharedMemory.h b/sensors/common/vts/utils/include/sensors-vts-utils/SensorsTestSharedMemory.h
index 055b8e7..002f42c 100644
--- a/sensors/common/vts/utils/include/sensors-vts-utils/SensorsTestSharedMemory.h
+++ b/sensors/common/vts/utils/include/sensors-vts-utils/SensorsTestSharedMemory.h
@@ -33,6 +33,7 @@
     static SensorsTestSharedMemory* create(SharedMemType type, size_t size);
     SharedMemInfo getSharedMemInfo() const;
     char* getBuffer() const;
+    size_t getSize() const;
     std::vector<Event> parseEvents(int64_t lastCounter = -1, size_t offset = 0) const;
     virtual ~SensorsTestSharedMemory();
 
diff --git a/soundtrigger/2.0/vts/functional/Android.bp b/soundtrigger/2.0/vts/functional/Android.bp
index be6b3a8..f6207c4 100644
--- a/soundtrigger/2.0/vts/functional/Android.bp
+++ b/soundtrigger/2.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalSoundtriggerV2_0TargetTest.cpp"],
     static_libs: ["android.hardware.soundtrigger@2.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/soundtrigger/2.1/vts/functional/Android.bp b/soundtrigger/2.1/vts/functional/Android.bp
index 925a17c..f1eb35d 100644
--- a/soundtrigger/2.1/vts/functional/Android.bp
+++ b/soundtrigger/2.1/vts/functional/Android.bp
@@ -25,4 +25,5 @@
                  "android.hardware.soundtrigger@2.1",
                  "libhidlmemory"
                  ],
+    test_suites: ["general-tests"],
 }
diff --git a/soundtrigger/2.2/ISoundTriggerHw.hal b/soundtrigger/2.2/ISoundTriggerHw.hal
index fcb5087..a26896a 100644
--- a/soundtrigger/2.2/ISoundTriggerHw.hal
+++ b/soundtrigger/2.2/ISoundTriggerHw.hal
@@ -16,25 +16,27 @@
 
 package android.hardware.soundtrigger@2.2;
 
-import @2.0::ISoundTriggerHwCallback.RecognitionEvent;
 import @2.0::SoundModelHandle;
 import @2.1::ISoundTriggerHw;
 
 /**
- * SoundTrigger HAL interface. Used for hardware recognition of hotwords.
+ * SoundTrigger HAL interface. Used for hardware recognition of hotwords
+ * and other sounds.
  */
 interface ISoundTriggerHw extends @2.1::ISoundTriggerHw {
 
     /**
      * Get the state of a given model.
-     * The model state is returned as a RecognitionEvent.
-     * @param modelHandle The handle of the sound model to use for recognition
+     * The model state is returned asynchronously as a RecognitionEvent via
+     * the callback that was registered in StartRecognition().
+     * @param modelHandle The handle of the sound model whose state is being
+     *                    queried.
      * @return retval Operation completion status: 0 in case of success,
      *                -ENOSYS in case of invalid model handle,
      *                -ENOMEM in case of memory allocation failure,
-     *                -ENODEV in case of initialization error.
-     * @return state  RecognitionEvent in case of success
+     *                -ENODEV in case of initialization error,
+     *                -EINVAL in case where a recognition event is already
+     *                        being processed.
      */
-    getModelState(SoundModelHandle modelHandle)
-            generates (int32_t retval, @2.0::ISoundTriggerHwCallback.RecognitionEvent state);
+    getModelState(SoundModelHandle modelHandle) generates (int32_t retval);
 };
diff --git a/soundtrigger/2.2/default/SoundTriggerHw.cpp b/soundtrigger/2.2/default/SoundTriggerHw.cpp
index ffdf9fb..9d930ac 100644
--- a/soundtrigger/2.2/default/SoundTriggerHw.cpp
+++ b/soundtrigger/2.2/default/SoundTriggerHw.cpp
@@ -690,45 +690,26 @@
 
 // Begin V2_2 implementation
 
-Return<void> SoundTriggerHw::getModelState(int32_t modelHandle, getModelState_cb hidl_cb) {
-    int ret = 0;
-    V2_0::ISoundTriggerHwCallback::RecognitionEvent event;
-    struct sound_trigger_recognition_event* halEvent = NULL;
+Return<int32_t> SoundTriggerHw::getModelState(int32_t modelHandle) {
     sp<SoundModelClient> client;
     if (mHwDevice == NULL) {
-        ret = -ENODEV;
-        goto exit;
+        return -ENODEV;
     }
 
     {
         AutoMutex lock(mLock);
         client = mClients.valueFor(modelHandle);
         if (client == 0) {
-            ret = -ENOSYS;
-            goto exit;
+            return -ENOSYS;
         }
     }
 
     if (mHwDevice->get_model_state == NULL) {
         ALOGE("Failed to get model state from device, no such method");
-        ret = -ENODEV;
-        goto exit;
+        return -ENODEV;
     }
 
-    // Get the state from the device (as a recognition event)
-    halEvent = mHwDevice->get_model_state(mHwDevice, client->getHalHandle());
-    if (halEvent == NULL) {
-        ALOGE("Failed to get model state from device");
-        ret = -ENODEV;
-        goto exit;
-    }
-
-    convertRecognitionEventFromHal(&event, halEvent);
-
-exit:
-    hidl_cb(ret, event);
-    free(halEvent);
-    return Void();
+    return mHwDevice->get_model_state(mHwDevice, client->getHalHandle());
 }
 
 // Methods from ::android::hidl::base::V1_0::IBase follow.
diff --git a/soundtrigger/2.2/default/SoundTriggerHw.h b/soundtrigger/2.2/default/SoundTriggerHw.h
index 876b990..6676318 100644
--- a/soundtrigger/2.2/default/SoundTriggerHw.h
+++ b/soundtrigger/2.2/default/SoundTriggerHw.h
@@ -82,7 +82,7 @@
                                          int32_t cookie) override;
 
     // Methods from V2_2::ISoundTriggerHw follow.
-    Return<void> getModelState(int32_t modelHandle, getModelState_cb _hidl_cb) override;
+    Return<int32_t> getModelState(int32_t modelHandle) override;
 
     SoundTriggerHw();
 
diff --git a/soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp b/soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp
index a473c37..0f37816 100644
--- a/soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp
+++ b/soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp
@@ -74,21 +74,14 @@
  * Test ISoundTriggerHw::getModelState() method
  *
  * Verifies that:
- *  - the implementation returns -EINVAL with invalid model handle
+ *  - the implementation returns -ENOSYS with invalid model handle
  *
  */
 TEST_F(SoundTriggerHidlTest, GetModelStateInvalidModel) {
-    int ret = android::OK;
-    ::android::hardware::soundtrigger::V2_0::ISoundTriggerHwCallback::RecognitionEvent event;
     SoundModelHandle handle = 0;
-    Return<void> hidlReturn =
-        mSoundTriggerHal->getModelState(handle, [&](int32_t retval, auto res) {
-            ret = retval;
-            event = res;
-        });
-
+    Return<int32_t> hidlReturn = mSoundTriggerHal->getModelState(handle);
     EXPECT_TRUE(hidlReturn.isOk());
-    EXPECT_EQ(-ENOSYS, ret);
+    EXPECT_EQ(-ENOSYS, hidlReturn);
 }
 
 int main(int argc, char** argv) {
diff --git a/tests/msgq/1.0/default/Android.bp b/tests/msgq/1.0/default/Android.bp
index 6bbca24..6c8be6c 100644
--- a/tests/msgq/1.0/default/Android.bp
+++ b/tests/msgq/1.0/default/Android.bp
@@ -54,6 +54,7 @@
         "libutils",
         "android.hardware.tests.msgq@1.0"
     ],
+    test_suites: ["general-tests"],
 }
 
 cc_test {
@@ -80,4 +81,5 @@
     // libs should be used on device.
     static_libs: ["android.hardware.tests.msgq@1.0"],
     whole_static_libs: ["android.hardware.tests.msgq@1.0-impl"],
+    test_suites: ["general-tests"],
 }
diff --git a/tests/safeunion/cpp/1.0/.hidl_for_test b/tests/safeunion/cpp/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/safeunion/cpp/1.0/.hidl_for_test
diff --git a/tests/safeunion/cpp/1.0/Android.bp b/tests/safeunion/cpp/1.0/Android.bp
new file mode 100644
index 0000000..1111719
--- /dev/null
+++ b/tests/safeunion/cpp/1.0/Android.bp
@@ -0,0 +1,14 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "android.hardware.tests.safeunion.cpp@1.0",
+    root: "android.hardware",
+    srcs: [
+        "ICppSafeUnion.hal",
+    ],
+    interfaces: [
+        "android.hidl.base@1.0",
+    ],
+    gen_java: false,
+}
+
diff --git a/tests/safeunion/cpp/1.0/ICppSafeUnion.hal b/tests/safeunion/cpp/1.0/ICppSafeUnion.hal
new file mode 100644
index 0000000..cc1a91e
--- /dev/null
+++ b/tests/safeunion/cpp/1.0/ICppSafeUnion.hal
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.tests.safeunion.cpp@1.0;
+
+/**
+ * Safe union for cpp-only types.
+ */
+interface ICppSafeUnion {
+    safe_union PointerFmqSafeUnion {
+        interface iface;
+        fmq_sync<uint8_t> fmqSync;
+        fmq_unsync<uint8_t> fmqUnsync;
+    };
+    safe_union FmqSafeUnion {
+        fmq_sync<uint8_t> fmqSync;
+        fmq_unsync<uint8_t> fmqUnsync;
+    };
+
+    repeatPointerFmqSafeUnion(PointerFmqSafeUnion fmq) generates (PointerFmqSafeUnion fmq);
+    repeatFmqSafeUnion(FmqSafeUnion fmq) generates (FmqSafeUnion fmq);
+};
diff --git a/tests/safeunion/cpp/1.0/default/Android.bp b/tests/safeunion/cpp/1.0/default/Android.bp
new file mode 100644
index 0000000..210a639
--- /dev/null
+++ b/tests/safeunion/cpp/1.0/default/Android.bp
@@ -0,0 +1,22 @@
+cc_library {
+    name: "android.hardware.tests.safeunion.cpp@1.0-impl",
+    relative_install_path: "hw",
+    srcs: [
+        "CppSafeUnion.cpp",
+    ],
+    shared_libs: [
+        "libbase",
+        "libcutils",
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+    ],
+
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: [
+        "android.hardware.tests.safeunion.cpp@1.0",
+    ],
+}
diff --git a/tests/safeunion/cpp/1.0/default/CppSafeUnion.cpp b/tests/safeunion/cpp/1.0/default/CppSafeUnion.cpp
new file mode 100644
index 0000000..dcbd9d7
--- /dev/null
+++ b/tests/safeunion/cpp/1.0/default/CppSafeUnion.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2018 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 "CppSafeUnion.h"
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace safeunion {
+namespace cpp {
+namespace V1_0 {
+namespace implementation {
+
+Return<void> CppSafeUnion::repeatPointerFmqSafeUnion(const ICppSafeUnion::PointerFmqSafeUnion& fmq,
+                                                     repeatPointerFmqSafeUnion_cb _hidl_cb) {
+    _hidl_cb(fmq);
+    return Void();
+}
+
+Return<void> CppSafeUnion::repeatFmqSafeUnion(const ICppSafeUnion::FmqSafeUnion& fmq,
+                                              repeatFmqSafeUnion_cb _hidl_cb) {
+    _hidl_cb(fmq);
+    return Void();
+}
+
+ICppSafeUnion* HIDL_FETCH_ICppSafeUnion(const char* /* name */) {
+    return new CppSafeUnion();
+}
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace cpp
+}  // namespace safeunion
+}  // namespace tests
+}  // namespace hardware
+}  // namespace android
diff --git a/tests/safeunion/cpp/1.0/default/CppSafeUnion.h b/tests/safeunion/cpp/1.0/default/CppSafeUnion.h
new file mode 100644
index 0000000..a128273
--- /dev/null
+++ b/tests/safeunion/cpp/1.0/default/CppSafeUnion.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#pragma once
+
+#include <android/hardware/tests/safeunion/cpp/1.0/ICppSafeUnion.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace safeunion {
+namespace cpp {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::sp;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+
+struct CppSafeUnion : public ICppSafeUnion {
+    Return<void> repeatPointerFmqSafeUnion(const ICppSafeUnion::PointerFmqSafeUnion& fmq,
+                                           repeatPointerFmqSafeUnion_cb _hidl_cb) override;
+    Return<void> repeatFmqSafeUnion(const ICppSafeUnion::FmqSafeUnion& fmq,
+                                    repeatFmqSafeUnion_cb _hidl_cb) override;
+};
+
+extern "C" ICppSafeUnion* HIDL_FETCH_ICppSafeUnion(const char* name);
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace cpp
+}  // namespace safeunion
+}  // namespace tests
+}  // namespace hardware
+}  // namespace android
diff --git a/tetheroffload/config/1.0/vts/functional/Android.bp b/tetheroffload/config/1.0/vts/functional/Android.bp
index dc95eaa..52b9810 100644
--- a/tetheroffload/config/1.0/vts/functional/Android.bp
+++ b/tetheroffload/config/1.0/vts/functional/Android.bp
@@ -17,4 +17,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalTetheroffloadConfigV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.tetheroffload.config@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/tetheroffload/control/1.0/vts/functional/Android.bp b/tetheroffload/control/1.0/vts/functional/Android.bp
index c6216a2..e8e1414 100644
--- a/tetheroffload/control/1.0/vts/functional/Android.bp
+++ b/tetheroffload/control/1.0/vts/functional/Android.bp
@@ -20,4 +20,5 @@
         "android.hardware.tetheroffload.config@1.0",
         "android.hardware.tetheroffload.control@1.0",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/thermal/1.0/vts/functional/Android.bp b/thermal/1.0/vts/functional/Android.bp
index f661f1e..6bda558 100644
--- a/thermal/1.0/vts/functional/Android.bp
+++ b/thermal/1.0/vts/functional/Android.bp
@@ -19,5 +19,6 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalThermalV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.thermal@1.0"],
+    test_suites: ["general-tests"],
 }
 
diff --git a/thermal/1.1/vts/functional/Android.bp b/thermal/1.1/vts/functional/Android.bp
index f5f01fa..9a16c30 100644
--- a/thermal/1.1/vts/functional/Android.bp
+++ b/thermal/1.1/vts/functional/Android.bp
@@ -22,5 +22,6 @@
         "android.hardware.thermal@1.0",
         "android.hardware.thermal@1.1",
     ],
+    test_suites: ["general-tests"],
 }
 
diff --git a/thermal/2.0/types.hal b/thermal/2.0/types.hal
index 4929e44..a1c0325 100644
--- a/thermal/2.0/types.hal
+++ b/thermal/2.0/types.hal
@@ -48,27 +48,34 @@
      * Not under throttling.
      */
     NONE = 0,
+
     /**
      * Light throttling where UX is not impacted.
      */
     LIGHT,
+
     /**
-     * Moderate throttling where UX is not largily impacted.
+     * Moderate throttling where UX is not largely impacted.
      */
     MODERATE,
+
     /**
      * Severe throttling where UX is largely impacted.
      * Similar to 1.0 throttlingThreshold.
      */
     SEVERE,
+
     /**
      * Platform has done everything to reduce power.
      */
     CRITICAL,
+
     /**
-     * User should be warned before shutdown.
+     * Key components in platform are shutting down due to thermal condition.
+     * Device functionalities will be limited.
      */
-    WARNING,
+    EMERGENCY,
+
     /**
      * Need shutdown immediately.
      */
diff --git a/tv/input/1.0/vts/functional/Android.bp b/tv/input/1.0/vts/functional/Android.bp
index 978830c..29181b0 100644
--- a/tv/input/1.0/vts/functional/Android.bp
+++ b/tv/input/1.0/vts/functional/Android.bp
@@ -19,5 +19,6 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalTvInputV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.tv.input@1.0"],
+    test_suites: ["general-tests"],
 }
 
diff --git a/usb/1.0/vts/functional/Android.bp b/usb/1.0/vts/functional/Android.bp
index 96d3c0e..683ee17 100644
--- a/usb/1.0/vts/functional/Android.bp
+++ b/usb/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalUsbV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.usb@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/usb/1.1/vts/functional/Android.bp b/usb/1.1/vts/functional/Android.bp
index 4bb3203..1f0972f 100644
--- a/usb/1.1/vts/functional/Android.bp
+++ b/usb/1.1/vts/functional/Android.bp
@@ -22,5 +22,6 @@
         "android.hardware.usb@1.0",
         "android.hardware.usb@1.1",
     ],
+    test_suites: ["general-tests"],
 }
 
diff --git a/vibrator/1.0/vts/functional/Android.bp b/vibrator/1.0/vts/functional/Android.bp
index 016d627..391d3d4 100644
--- a/vibrator/1.0/vts/functional/Android.bp
+++ b/vibrator/1.0/vts/functional/Android.bp
@@ -19,5 +19,6 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalVibratorV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.vibrator@1.0"],
+    test_suites: ["general-tests"],
 }
 
diff --git a/vibrator/1.1/vts/functional/Android.bp b/vibrator/1.1/vts/functional/Android.bp
index 4f6454b..c65ff41 100644
--- a/vibrator/1.1/vts/functional/Android.bp
+++ b/vibrator/1.1/vts/functional/Android.bp
@@ -22,5 +22,6 @@
         "android.hardware.vibrator@1.0",
         "android.hardware.vibrator@1.1",
     ],
+    test_suites: ["general-tests"],
 }
 
diff --git a/vibrator/1.2/vts/functional/Android.bp b/vibrator/1.2/vts/functional/Android.bp
index 3a4e2ef..1e3ec97 100644
--- a/vibrator/1.2/vts/functional/Android.bp
+++ b/vibrator/1.2/vts/functional/Android.bp
@@ -23,5 +23,6 @@
         "android.hardware.vibrator@1.1",
         "android.hardware.vibrator@1.2",
     ],
+    test_suites: ["general-tests"],
 }
 
diff --git a/vr/1.0/vts/functional/Android.bp b/vr/1.0/vts/functional/Android.bp
index 4029137..958cce7 100644
--- a/vr/1.0/vts/functional/Android.bp
+++ b/vr/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalVrV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.vr@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/weaver/1.0/vts/functional/Android.bp b/weaver/1.0/vts/functional/Android.bp
index 0089d89..9fdbb18 100644
--- a/weaver/1.0/vts/functional/Android.bp
+++ b/weaver/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalWeaverV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.weaver@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/wifi/1.0/vts/functional/Android.bp b/wifi/1.0/vts/functional/Android.bp
index d0dd915..3189db4 100644
--- a/wifi/1.0/vts/functional/Android.bp
+++ b/wifi/1.0/vts/functional/Android.bp
@@ -48,6 +48,7 @@
         "android.hardware.wifi@1.2",
         "android.hardware.wifi@1.3",
     ],
+    test_suites: ["general-tests"],
 }
 
 cc_test {
@@ -61,4 +62,5 @@
         "VtsHalWifiV1_0TargetTestUtil",
         "android.hardware.wifi@1.0",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/wifi/1.1/vts/functional/Android.bp b/wifi/1.1/vts/functional/Android.bp
index 1b0c12d..78d7a85 100644
--- a/wifi/1.1/vts/functional/Android.bp
+++ b/wifi/1.1/vts/functional/Android.bp
@@ -25,4 +25,5 @@
         "android.hardware.wifi@1.0",
         "android.hardware.wifi@1.1",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/wifi/1.2/vts/functional/Android.bp b/wifi/1.2/vts/functional/Android.bp
index c5a6e84..a969f65 100644
--- a/wifi/1.2/vts/functional/Android.bp
+++ b/wifi/1.2/vts/functional/Android.bp
@@ -28,6 +28,7 @@
         "android.hardware.wifi@1.1",
         "android.hardware.wifi@1.2",
     ],
+    test_suites: ["general-tests"],
 }
 
 cc_test {
@@ -43,4 +44,5 @@
         "android.hardware.wifi@1.1",
         "android.hardware.wifi@1.2",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/wifi/1.3/Android.bp b/wifi/1.3/Android.bp
index 5e87c1c..163a870 100644
--- a/wifi/1.3/Android.bp
+++ b/wifi/1.3/Android.bp
@@ -9,6 +9,7 @@
     srcs: [
         "types.hal",
         "IWifi.hal",
+        "IWifiChip.hal",
         "IWifiStaIface.hal",
     ],
     interfaces: [
diff --git a/wifi/1.3/IWifiChip.hal b/wifi/1.3/IWifiChip.hal
new file mode 100644
index 0000000..74d527d
--- /dev/null
+++ b/wifi/1.3/IWifiChip.hal
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi@1.3;
+
+import @1.0::WifiStatus;
+import @1.2::IWifiChip;
+
+/**
+ * Interface that represents a chip that must be configured as a single unit.
+ */
+interface IWifiChip extends @1.2::IWifiChip {
+
+    /**
+     * Capabilities exposed by this chip.
+     */
+    enum ChipCapabilityMask : @1.2::IWifiChip.ChipCapabilityMask {
+        /**
+         * Set Latency Mode.
+         */
+         SET_LATENCY_MODE = 1 << 12
+    };
+
+    /**
+     * Get the capabilities supported by this chip.
+     *
+     * @return status WifiStatus of the operation.
+     *         Possible status codes:
+     *         |WifiStatusCode.SUCCESS|,
+     *         |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|,
+     *         |WifiStatusCode.ERROR_NOT_AVAILABLE|,
+     *         |WifiStatusCode.ERROR_UNKNOWN|
+     * @return capabilities Bitset of |ChipCapabilityMask| values.
+     */
+    getCapabilities_1_3()
+      generates (WifiStatus status, bitfield<ChipCapabilityMask> capabilities);
+
+    /**
+     * This enum represents the different latency modes that can be set through
+     * setLatencyMode()
+     */
+    enum LatencyMode : uint32_t {
+        NORMAL    = 0,
+        LOW       = 1
+    };
+
+    /**
+     * API to set the wifi latency mode
+     *
+     * Latency mode determines whether or not to optimize for reducing wifi
+     * latency as a tradeoff with other wifi functionality such as scanning,
+     * roaming, etc. This optimization is suitable for some applications such
+     * as gaming and virtual reality applications.
+     */
+    setLatencyMode(LatencyMode mode) generates (WifiStatus status);
+};
diff --git a/wifi/1.3/default/hidl_struct_util.cpp b/wifi/1.3/default/hidl_struct_util.cpp
index c88ddaa..b3d612f 100644
--- a/wifi/1.3/default/hidl_struct_util.cpp
+++ b/wifi/1.3/default/hidl_struct_util.cpp
@@ -69,9 +69,9 @@
     return {};
 }
 
-V1_2::IWifiChip::ChipCapabilityMask convertLegacyFeatureToHidlChipCapability(
+V1_3::IWifiChip::ChipCapabilityMask convertLegacyFeatureToHidlChipCapability(
     uint32_t feature) {
-    using HidlChipCaps = V1_2::IWifiChip::ChipCapabilityMask;
+    using HidlChipCaps = V1_3::IWifiChip::ChipCapabilityMask;
     switch (feature) {
         case WIFI_FEATURE_SET_TX_POWER_LIMIT:
             return HidlChipCaps::SET_TX_POWER_LIMIT;
@@ -81,6 +81,8 @@
             return HidlChipCaps::D2D_RTT;
         case WIFI_FEATURE_D2AP_RTT:
             return HidlChipCaps::D2AP_RTT;
+        case WIFI_FEATURE_SET_LATENCY_MODE:
+            return HidlChipCaps::SET_LATENCY_MODE;
     };
     CHECK(false) << "Unknown legacy feature: " << feature;
     return {};
@@ -141,7 +143,8 @@
     }
     for (const auto feature :
          {WIFI_FEATURE_SET_TX_POWER_LIMIT, WIFI_FEATURE_USE_BODY_HEAD_SAR,
-          WIFI_FEATURE_D2D_RTT, WIFI_FEATURE_D2AP_RTT}) {
+          WIFI_FEATURE_D2D_RTT, WIFI_FEATURE_D2AP_RTT,
+          WIFI_FEATURE_SET_LATENCY_MODE}) {
         if (feature & legacy_feature_set) {
             *hidl_caps |= convertLegacyFeatureToHidlChipCapability(feature);
         }
@@ -292,6 +295,17 @@
     CHECK(false);
 }
 
+legacy_hal::wifi_latency_mode convertHidlLatencyModeToLegacy(
+    IWifiChip::LatencyMode hidl_latency_mode) {
+    switch (hidl_latency_mode) {
+        case IWifiChip::LatencyMode::NORMAL:
+            return legacy_hal::WIFI_LATENCY_MODE_NORMAL;
+        case IWifiChip::LatencyMode::LOW:
+            return legacy_hal::WIFI_LATENCY_MODE_LOW;
+    }
+    CHECK(false);
+}
+
 bool convertLegacyWifiMacInfoToHidl(
     const legacy_hal::WifiMacInfo& legacy_mac_info,
     V1_2::IWifiChipEventCallback::RadioModeInfo* hidl_radio_mode_info) {
diff --git a/wifi/1.3/default/hidl_struct_util.h b/wifi/1.3/default/hidl_struct_util.h
index 8df484d..3eefd95 100644
--- a/wifi/1.3/default/hidl_struct_util.h
+++ b/wifi/1.3/default/hidl_struct_util.h
@@ -21,9 +21,9 @@
 
 #include <android/hardware/wifi/1.0/IWifiChip.h>
 #include <android/hardware/wifi/1.0/types.h>
-#include <android/hardware/wifi/1.2/IWifiChip.h>
 #include <android/hardware/wifi/1.2/IWifiChipEventCallback.h>
 #include <android/hardware/wifi/1.2/types.h>
+#include <android/hardware/wifi/1.3/IWifiChip.h>
 #include <android/hardware/wifi/1.3/types.h>
 
 #include "wifi_legacy_hal.h"
@@ -57,6 +57,8 @@
     WifiDebugHostWakeReasonStats* hidl_stats);
 legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
     V1_1::IWifiChip::TxPowerScenario hidl_scenario);
+legacy_hal::wifi_latency_mode convertHidlLatencyModeToLegacy(
+    V1_3::IWifiChip::LatencyMode hidl_latency_mode);
 legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy_1_2(
     V1_2::IWifiChip::TxPowerScenario hidl_scenario);
 bool convertLegacyWifiMacInfosToHidl(
diff --git a/wifi/1.3/default/tests/hidl_struct_util_unit_tests.cpp b/wifi/1.3/default/tests/hidl_struct_util_unit_tests.cpp
index d600a2b..7056759 100644
--- a/wifi/1.3/default/tests/hidl_struct_util_unit_tests.cpp
+++ b/wifi/1.3/default/tests/hidl_struct_util_unit_tests.cpp
@@ -238,6 +238,27 @@
                   converted.radios[i].onTimeInMsForHs20Scan);
     }
 }
+
+TEST_F(HidlStructUtilTest, CanConvertLegacyFeaturesToHidl) {
+    using HidlChipCaps = V1_3::IWifiChip::ChipCapabilityMask;
+
+    uint32_t hidle_caps;
+
+    uint32_t legacy_feature_set =
+            WIFI_FEATURE_D2D_RTT | WIFI_FEATURE_SET_LATENCY_MODE;
+    uint32_t legacy_logger_feature_set =
+            legacy_hal::WIFI_LOGGER_DRIVER_DUMP_SUPPORTED;
+
+    ASSERT_TRUE(hidl_struct_util::convertLegacyFeaturesToHidlChipCapabilities(
+        legacy_feature_set, legacy_logger_feature_set, &hidle_caps));
+
+    EXPECT_EQ(HidlChipCaps::DEBUG_RING_BUFFER_VENDOR_DATA |
+                  HidlChipCaps::DEBUG_HOST_WAKE_REASON_STATS |
+                  HidlChipCaps::DEBUG_ERROR_ALERTS | HidlChipCaps::D2D_RTT |
+                  HidlChipCaps::SET_LATENCY_MODE |
+                  HidlChipCaps::DEBUG_MEMORY_DRIVER_DUMP,
+              hidle_caps);
+}
 }  // namespace implementation
 }  // namespace V1_3
 }  // namespace wifi
diff --git a/wifi/1.3/default/wifi_chip.cpp b/wifi/1.3/default/wifi_chip.cpp
index faf1862..a80116a 100644
--- a/wifi/1.3/default/wifi_chip.cpp
+++ b/wifi/1.3/default/wifi_chip.cpp
@@ -561,6 +561,13 @@
                            hidl_status_cb);
 }
 
+Return<void> WifiChip::setLatencyMode(LatencyMode mode,
+                                      setLatencyMode_cb hidl_status_cb) {
+    return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+                           &WifiChip::setLatencyModeInternal, hidl_status_cb,
+                           mode);
+}
+
 Return<void> WifiChip::registerEventCallback_1_2(
     const sp<V1_2::IWifiChipEventCallback>& event_callback,
     registerEventCallback_cb hidl_status_cb) {
@@ -576,6 +583,12 @@
                            hidl_status_cb, scenario);
 }
 
+Return<void> WifiChip::getCapabilities_1_3(getCapabilities_cb hidl_status_cb) {
+    return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+                           &WifiChip::getCapabilitiesInternal_1_3,
+                           hidl_status_cb);
+}
+
 Return<void> WifiChip::debug(const hidl_handle& handle,
                              const hidl_vec<hidl_string>&) {
     if (handle != nullptr && handle->numFds >= 1) {
@@ -618,6 +631,11 @@
 }
 
 std::pair<WifiStatus, uint32_t> WifiChip::getCapabilitiesInternal() {
+    // Deprecated support for this callback.
+    return {createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED), 0};
+}
+
+std::pair<WifiStatus, uint32_t> WifiChip::getCapabilitiesInternal_1_3() {
     legacy_hal::wifi_error legacy_status;
     uint32_t legacy_feature_set;
     uint32_t legacy_logger_feature_set;
@@ -1058,6 +1076,13 @@
     return createWifiStatusFromLegacyError(legacy_status);
 }
 
+WifiStatus WifiChip::setLatencyModeInternal(LatencyMode mode) {
+    auto legacy_status = legacy_hal_.lock()->setLatencyMode(
+        getWlan0IfaceName(),
+        hidl_struct_util::convertHidlLatencyModeToLegacy(mode));
+    return createWifiStatusFromLegacyError(legacy_status);
+}
+
 WifiStatus WifiChip::registerEventCallbackInternal_1_2(
     const sp<V1_2::IWifiChipEventCallback>& event_callback) {
     if (!event_cb_handler_.addCallback(event_callback)) {
diff --git a/wifi/1.3/default/wifi_chip.h b/wifi/1.3/default/wifi_chip.h
index ba60a8e..11200f9 100644
--- a/wifi/1.3/default/wifi_chip.h
+++ b/wifi/1.3/default/wifi_chip.h
@@ -21,7 +21,7 @@
 #include <map>
 
 #include <android-base/macros.h>
-#include <android/hardware/wifi/1.2/IWifiChip.h>
+#include <android/hardware/wifi/1.3/IWifiChip.h>
 
 #include "hidl_callback_util.h"
 #include "ringbuffer.h"
@@ -46,7 +46,7 @@
  * Since there is only a single chip instance used today, there is no
  * identifying handle information stored here.
  */
-class WifiChip : public V1_2::IWifiChip {
+class WifiChip : public V1_3::IWifiChip {
    public:
     WifiChip(
         ChipId chip_id,
@@ -137,12 +137,16 @@
         selectTxPowerScenario_cb hidl_status_cb) override;
     Return<void> resetTxPowerScenario(
         resetTxPowerScenario_cb hidl_status_cb) override;
+    Return<void> setLatencyMode(LatencyMode mode,
+                                setLatencyMode_cb hidl_status_cb) override;
     Return<void> registerEventCallback_1_2(
         const sp<V1_2::IWifiChipEventCallback>& event_callback,
         registerEventCallback_1_2_cb hidl_status_cb) override;
     Return<void> selectTxPowerScenario_1_2(
         TxPowerScenario scenario,
         selectTxPowerScenario_cb hidl_status_cb) override;
+    Return<void> getCapabilities_1_3(
+        getCapabilities_cb hidl_status_cb) override;
     Return<void> debug(const hidl_handle& handle,
                        const hidl_vec<hidl_string>& options) override;
 
@@ -201,9 +205,11 @@
     WifiStatus selectTxPowerScenarioInternal(
         V1_1::IWifiChip::TxPowerScenario scenario);
     WifiStatus resetTxPowerScenarioInternal();
+    WifiStatus setLatencyModeInternal(LatencyMode mode);
     WifiStatus registerEventCallbackInternal_1_2(
         const sp<V1_2::IWifiChipEventCallback>& event_callback);
     WifiStatus selectTxPowerScenarioInternal_1_2(TxPowerScenario scenario);
+    std::pair<WifiStatus, uint32_t> getCapabilitiesInternal_1_3();
     WifiStatus handleChipConfiguration(
         std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id);
     WifiStatus registerDebugRingBufferCallback();
diff --git a/wifi/1.3/default/wifi_legacy_hal.cpp b/wifi/1.3/default/wifi_legacy_hal.cpp
index 817c860..2cd7c2a 100644
--- a/wifi/1.3/default/wifi_legacy_hal.cpp
+++ b/wifi/1.3/default/wifi_legacy_hal.cpp
@@ -796,6 +796,12 @@
         getIfaceHandle(iface_name));
 }
 
+wifi_error WifiLegacyHal::setLatencyMode(const std::string& iface_name,
+                                         wifi_latency_mode mode) {
+    return global_func_table_.wifi_set_latency_mode(getIfaceHandle(iface_name),
+                                                    mode);
+}
+
 std::pair<wifi_error, uint32_t> WifiLegacyHal::getLoggerSupportedFeatureSet(
     const std::string& iface_name) {
     uint32_t supported_feature_flags;
diff --git a/wifi/1.3/default/wifi_legacy_hal.h b/wifi/1.3/default/wifi_legacy_hal.h
index af654fa..2f513c4 100644
--- a/wifi/1.3/default/wifi_legacy_hal.h
+++ b/wifi/1.3/default/wifi_legacy_hal.h
@@ -254,6 +254,8 @@
     wifi_error selectTxPowerScenario(const std::string& iface_name,
                                      wifi_power_scenario scenario);
     wifi_error resetTxPowerScenario(const std::string& iface_name);
+    wifi_error setLatencyMode(const std::string& iface_name,
+                              wifi_latency_mode mode);
     // Logger/debug functions.
     std::pair<wifi_error, uint32_t> getLoggerSupportedFeatureSet(
         const std::string& iface_name);
diff --git a/wifi/1.3/default/wifi_legacy_hal_stubs.cpp b/wifi/1.3/default/wifi_legacy_hal_stubs.cpp
index 942df2a..dedd2d4 100644
--- a/wifi/1.3/default/wifi_legacy_hal_stubs.cpp
+++ b/wifi/1.3/default/wifi_legacy_hal_stubs.cpp
@@ -137,6 +137,7 @@
     populateStubFor(&hal_fn->wifi_select_tx_power_scenario);
     populateStubFor(&hal_fn->wifi_reset_tx_power_scenario);
     populateStubFor(&hal_fn->wifi_set_radio_mode_change_handler);
+    populateStubFor(&hal_fn->wifi_set_latency_mode);
     return true;
 }
 }  // namespace legacy_hal
diff --git a/wifi/1.3/vts/functional/Android.bp b/wifi/1.3/vts/functional/Android.bp
index dbe77bd..f5a0999 100644
--- a/wifi/1.3/vts/functional/Android.bp
+++ b/wifi/1.3/vts/functional/Android.bp
@@ -19,6 +19,7 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: [
         "VtsHalWifiV1_3TargetTest.cpp",
+        "wifi_chip_hidl_test.cpp",
     ],
     static_libs: [
         "VtsHalWifiV1_0TargetTestUtil",
diff --git a/wifi/1.3/vts/functional/wifi_chip_hidl_test.cpp b/wifi/1.3/vts/functional/wifi_chip_hidl_test.cpp
new file mode 100644
index 0000000..d980fcb
--- /dev/null
+++ b/wifi/1.3/vts/functional/wifi_chip_hidl_test.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android-base/logging.h>
+
+#include <android/hardware/wifi/1.3/IWifiChip.h>
+
+#include <VtsHalHidlTargetTestBase.h>
+
+#include "wifi_hidl_call_util.h"
+#include "wifi_hidl_test_utils.h"
+
+using ::android::sp;
+using ::android::hardware::wifi::V1_0::ChipModeId;
+using ::android::hardware::wifi::V1_0::IfaceType;
+using ::android::hardware::wifi::V1_0::WifiStatusCode;
+using ::android::hardware::wifi::V1_3::IWifiChip;
+
+namespace {
+constexpr IWifiChip::LatencyMode kLatencyModeNormal =
+    IWifiChip::LatencyMode::NORMAL;
+
+constexpr IWifiChip::LatencyMode kLatencyModeLow = IWifiChip::LatencyMode::LOW;
+};  // namespace
+
+/**
+ * Fixture to use for all Wifi chip HIDL interface tests.
+ */
+class WifiChipHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+   public:
+    virtual void SetUp() override {
+        wifi_chip_ = IWifiChip::castFrom(getWifiChip());
+        ASSERT_NE(nullptr, wifi_chip_.get());
+    }
+
+    virtual void TearDown() override { stopWifi(); }
+
+   protected:
+    // Helper function to configure the Chip in one of the supported modes.
+    // Most of the non-mode-configuration-related methods require chip
+    // to be first configured.
+    ChipModeId configureChipForIfaceType(IfaceType type, bool expectSuccess) {
+        ChipModeId mode_id;
+        EXPECT_EQ(expectSuccess,
+                  configureChipToSupportIfaceType(wifi_chip_, type, &mode_id));
+        return mode_id;
+    }
+
+    uint32_t configureChipForStaIfaceAndGetCapabilities() {
+        ChipModeId mode_id;
+        EXPECT_TRUE(configureChipToSupportIfaceType(wifi_chip_, IfaceType::STA,
+                                                    &mode_id));
+        const auto& status_and_caps =
+            HIDL_INVOKE(wifi_chip_, getCapabilities_1_3);
+        EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_caps.first.code);
+        return status_and_caps.second;
+    }
+
+    sp<IWifiChip> wifi_chip_;
+};
+
+/*
+ * SetLatencyMode_normal
+ * This test case tests the setLatencyMode() API with
+ * Latency mode NORMAL
+ */
+TEST_F(WifiChipHidlTest, SetLatencyMode_normal) {
+    uint32_t caps = configureChipForStaIfaceAndGetCapabilities();
+    const auto& status =
+        HIDL_INVOKE(wifi_chip_, setLatencyMode, kLatencyModeNormal);
+    if (caps & (IWifiChip::ChipCapabilityMask::SET_LATENCY_MODE)) {
+        EXPECT_EQ(WifiStatusCode::SUCCESS, status.code);
+    } else {
+        EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED, status.code);
+    }
+}
+
+/*
+ * SetLatencyMode_low
+ * This test case tests the setLatencyMode() API with Latency mode LOW
+ */
+TEST_F(WifiChipHidlTest, SetLatencyMode_low) {
+    uint32_t caps = configureChipForStaIfaceAndGetCapabilities();
+    const auto& status =
+        HIDL_INVOKE(wifi_chip_, setLatencyMode, kLatencyModeLow);
+    if (caps & (IWifiChip::ChipCapabilityMask::SET_LATENCY_MODE)) {
+        EXPECT_EQ(WifiStatusCode::SUCCESS, status.code);
+    } else {
+        EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED, status.code);
+    }
+}
+
+/*
+ * GetCapabilities_1_3
+ */
+TEST_F(WifiChipHidlTest, GetCapabilities_1_3) {
+    configureChipForIfaceType(IfaceType::STA, true);
+    const auto& status_and_caps = HIDL_INVOKE(wifi_chip_, getCapabilities_1_3);
+    if (status_and_caps.first.code != WifiStatusCode::SUCCESS) {
+        EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED,
+                  status_and_caps.first.code);
+        return;
+    }
+    EXPECT_NE(0u, status_and_caps.second);
+}
diff --git a/wifi/hostapd/1.0/vts/functional/Android.bp b/wifi/hostapd/1.0/vts/functional/Android.bp
index 7a920b4..79c5183 100644
--- a/wifi/hostapd/1.0/vts/functional/Android.bp
+++ b/wifi/hostapd/1.0/vts/functional/Android.bp
@@ -49,4 +49,5 @@
         "libwifi-system",
         "libwifi-system-iface",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/wifi/offload/1.0/vts/functional/Android.bp b/wifi/offload/1.0/vts/functional/Android.bp
index 140e45e..de15aa7 100644
--- a/wifi/offload/1.0/vts/functional/Android.bp
+++ b/wifi/offload/1.0/vts/functional/Android.bp
@@ -19,4 +19,5 @@
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalWifiOffloadV1_0TargetTest.cpp"],
     static_libs: ["android.hardware.wifi.offload@1.0"],
+    test_suites: ["general-tests"],
 }
diff --git a/wifi/supplicant/1.0/vts/functional/Android.bp b/wifi/supplicant/1.0/vts/functional/Android.bp
index ee6a68e..bdccac1 100644
--- a/wifi/supplicant/1.0/vts/functional/Android.bp
+++ b/wifi/supplicant/1.0/vts/functional/Android.bp
@@ -39,7 +39,6 @@
     srcs: [
         "VtsHalWifiSupplicantV1_0TargetTest.cpp",
         "supplicant_hidl_test.cpp",
-        "supplicant_p2p_iface_hidl_test.cpp",
         "supplicant_sta_iface_hidl_test.cpp",
         "supplicant_sta_network_hidl_test.cpp",
     ],
@@ -54,4 +53,25 @@
         "libwifi-system",
         "libwifi-system-iface",
     ],
+    test_suites: ["general-tests"],
+}
+
+cc_test {
+    name: "VtsHalWifiSupplicantP2pV1_0TargetTest",
+    defaults: ["VtsHalTargetTestDefaults"],
+    srcs: [
+        "VtsHalWifiSupplicantV1_0TargetTest.cpp",
+        "supplicant_p2p_iface_hidl_test.cpp",
+    ],
+    static_libs: [
+        "VtsHalWifiV1_0TargetTestUtil",
+        "VtsHalWifiSupplicantV1_0TargetTestUtil",
+        "android.hardware.wifi.supplicant@1.0",
+        "android.hardware.wifi.supplicant@1.1",
+        "android.hardware.wifi@1.0",
+        "libcrypto",
+        "libgmock",
+        "libwifi-system",
+        "libwifi-system-iface",
+    ],
 }
diff --git a/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp b/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
index adf2a85..6ca0546 100644
--- a/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
+++ b/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
@@ -44,7 +44,10 @@
     ::testing::AddGlobalTestEnvironment(gEnv);
     ::testing::InitGoogleTest(&argc, argv);
     gEnv->init(&argc, argv);
-    int status = RUN_ALL_TESTS();
-    LOG(INFO) << "Test result = " << status;
+    int status = gEnv->initFromOptions(argc, argv);
+    if (status == 0) {
+        int status = RUN_ALL_TESTS();
+        LOG(INFO) << "Test result = " << status;
+    }
     return status;
 }
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
index c6ac03c..436b88b 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
@@ -30,6 +30,8 @@
 using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
 using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
 
+extern WifiSupplicantHidlEnvironment* gEnv;
+
 class SupplicantHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    public:
     virtual void SetUp() override {
@@ -72,10 +74,13 @@
               std::find_if(ifaces.begin(), ifaces.end(), [](const auto& iface) {
                   return iface.type == IfaceType::STA;
               }));
-    EXPECT_NE(ifaces.end(),
-              std::find_if(ifaces.begin(), ifaces.end(), [](const auto& iface) {
-                  return iface.type == IfaceType::P2P;
-              }));
+    if (gEnv->isP2pOn) {
+        EXPECT_NE(
+            ifaces.end(),
+            std::find_if(ifaces.begin(), ifaces.end(), [](const auto& iface) {
+                return iface.type == IfaceType::P2P;
+            }));
+    }
 }
 
 /*
@@ -178,8 +183,10 @@
         IfaceType::STA, [](const SupplicantStatus& status) {
             EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
         });
-    supplicant_->setConcurrencyPriority(
-        IfaceType::P2P, [](const SupplicantStatus& status) {
-            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
-        });
+    if (gEnv->isP2pOn) {
+        supplicant_->setConcurrencyPriority(
+            IfaceType::P2P, [](const SupplicantStatus& status) {
+                EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+            });
+    }
 }
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp
index bdedfba..47c3056 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp
@@ -225,7 +225,9 @@
     // For 1.1 supplicant, we need to add interfaces at initialization.
     if (is_1_1(supplicant)) {
         addSupplicantStaIface_1_1(supplicant);
-        addSupplicantP2pIface_1_1(supplicant);
+        if (gEnv->isP2pOn) {
+            addSupplicantP2pIface_1_1(supplicant);
+        }
     }
     return supplicant;
 }
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h
index d4a768f..21a1ae6 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h
@@ -23,6 +23,8 @@
 #include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h>
 #include <android/hardware/wifi/supplicant/1.1/ISupplicant.h>
 
+#include <getopt.h>
+
 #include <VtsHalHidlTargetTestEnvBase.h>
 
 // Used to stop the android wifi framework before every test.
@@ -50,11 +52,48 @@
 
 class WifiSupplicantHidlEnvironment
     : public ::testing::VtsHalHidlTargetTestEnvBase {
-   public:
+   protected:
     virtual void HidlSetUp() override { stopSupplicant(); }
     virtual void HidlTearDown() override {
         startSupplicantAndWaitForHidlService();
     }
+
+   public:
+    // Whether P2P feature is supported on the device.
+    bool isP2pOn = true;
+
+    void usage(char* me, char* arg) {
+        fprintf(stderr,
+                "unrecognized option: %s\n\n"
+                "usage: %s <gtest options> <test options>\n\n"
+                "test options are:\n\n"
+                "-P, --p2p_on: Whether P2P feature is supported\n",
+                arg, me);
+    }
+
+    int initFromOptions(int argc, char** argv) {
+        static struct option options[] = {{"p2p_off", no_argument, 0, 'P'},
+                                          {0, 0, 0, 0}};
+
+        int c;
+        while ((c = getopt_long(argc, argv, "P", options, NULL)) >= 0) {
+            switch (c) {
+                case 'P':
+                    isP2pOn = false;
+                    break;
+                default:
+                    usage(argv[0], argv[optind]);
+                    return 2;
+            }
+        }
+
+        if (optind < argc) {
+            usage(argv[0], argv[optind]);
+            return 2;
+        }
+
+        return 0;
+    }
 };
 
 #endif /* SUPPLICANT_HIDL_TEST_UTILS_H */
diff --git a/wifi/supplicant/1.1/vts/functional/Android.bp b/wifi/supplicant/1.1/vts/functional/Android.bp
index 3e65453..353ae4b 100644
--- a/wifi/supplicant/1.1/vts/functional/Android.bp
+++ b/wifi/supplicant/1.1/vts/functional/Android.bp
@@ -56,4 +56,5 @@
         "libwifi-system",
         "libwifi-system-iface",
     ],
+    test_suites: ["general-tests"],
 }
diff --git a/wifi/supplicant/1.1/vts/functional/VtsHalWifiSupplicantV1_1TargetTest.cpp b/wifi/supplicant/1.1/vts/functional/VtsHalWifiSupplicantV1_1TargetTest.cpp
index 3d24fc3..9063a3b 100644
--- a/wifi/supplicant/1.1/vts/functional/VtsHalWifiSupplicantV1_1TargetTest.cpp
+++ b/wifi/supplicant/1.1/vts/functional/VtsHalWifiSupplicantV1_1TargetTest.cpp
@@ -30,8 +30,11 @@
         return instance;
     }
     virtual void registerTestServices() override {
+        registerTestService<::android::hardware::wifi::V1_0::IWifi>();
         registerTestService<::android::hardware::wifi::V1_1::IWifi>();
         registerTestService<
+            ::android::hardware::wifi::supplicant::V1_0::ISupplicant>();
+        registerTestService<
             ::android::hardware::wifi::supplicant::V1_1::ISupplicant>();
     }
 
@@ -46,7 +49,10 @@
     ::testing::AddGlobalTestEnvironment(gEnv);
     ::testing::InitGoogleTest(&argc, argv);
     gEnv->init(&argc, argv);
-    int status = RUN_ALL_TESTS();
-    LOG(INFO) << "Test result = " << status;
+    int status = gEnv->initFromOptions(argc, argv);
+    if (status == 0) {
+        int status = RUN_ALL_TESTS();
+        LOG(INFO) << "Test result = " << status;
+    }
     return status;
 }
diff --git a/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test.cpp b/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test.cpp
index 7e773d6..28f980c 100644
--- a/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test.cpp
+++ b/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test.cpp
@@ -33,6 +33,8 @@
 using ::android::hardware::wifi::supplicant::V1_1::ISupplicant;
 using ::android::sp;
 
+extern WifiSupplicantHidlEnvironment* gEnv;
+
 class SupplicantHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    public:
     virtual void SetUp() override {
@@ -81,6 +83,7 @@
  * AddP2pInterface
  */
 TEST_F(SupplicantHidlTest, AddP2pInterface) {
+    if (!gEnv->isP2pOn) return;
     ISupplicant::IfaceInfo iface_info;
     iface_info.name = getP2pIfaceName();
     iface_info.type = IfaceType::P2P;
@@ -120,6 +123,7 @@
  * RemoveP2pInterface
  */
 TEST_F(SupplicantHidlTest, RemoveP2pInterface) {
+    if (!gEnv->isP2pOn) return;
     ISupplicant::IfaceInfo iface_info;
     iface_info.name = getP2pIfaceName();
     iface_info.type = IfaceType::P2P;
diff --git a/wifi/supplicant/1.2/Android.bp b/wifi/supplicant/1.2/Android.bp
index bafd148..529dad4 100644
--- a/wifi/supplicant/1.2/Android.bp
+++ b/wifi/supplicant/1.2/Android.bp
@@ -7,6 +7,9 @@
         enabled: true,
     },
     srcs: [
+        "ISupplicant.hal",
+        "ISupplicantP2pIface.hal",
+        "ISupplicantStaIface.hal",
         "ISupplicantStaNetwork.hal",
     ],
     interfaces: [
diff --git a/wifi/supplicant/1.2/ISupplicant.hal b/wifi/supplicant/1.2/ISupplicant.hal
new file mode 100644
index 0000000..b0ec65d
--- /dev/null
+++ b/wifi/supplicant/1.2/ISupplicant.hal
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi.supplicant@1.2;
+
+import @1.1::ISupplicant;
+
+/**
+ * Interface exposed by the supplicant HIDL service registered
+ * with the hardware service manager.
+ * This is the root level object for any the supplicant interactions.
+ * To use 1.2 features you must cast specific interfaces returned from the
+ * 1.1 HAL. For example V1_1::ISupplicant::addIface() adds V1_1::ISupplicantIface,
+ * which can be cast to V1_2::ISupplicantStaIface.
+ */
+interface ISupplicant extends @1.1::ISupplicant {
+};
diff --git a/wifi/supplicant/1.2/ISupplicantP2pIface.hal b/wifi/supplicant/1.2/ISupplicantP2pIface.hal
new file mode 100644
index 0000000..7f6970f
--- /dev/null
+++ b/wifi/supplicant/1.2/ISupplicantP2pIface.hal
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi.supplicant@1.2;
+
+import @1.0::ISupplicantP2pIface;
+import @1.0::MacAddress;
+import @1.0::Ssid;
+import @1.0::SupplicantStatus;
+
+/**
+ * Interface exposed by the supplicant for each P2P mode network
+ * interface (e.g p2p0) it controls.
+ * To use 1.2 features you must cast specific interfaces returned from the
+ * 1.2 HAL. For example V1_2::ISupplicant::addIface() adds V1_2::ISupplicantIface,
+ * which can be cast to V1_2::ISupplicantP2pIface.
+ */
+interface ISupplicantP2pIface extends @1.0::ISupplicantP2pIface {
+    /**
+     * Set up a P2P group owner or join a group as a group client
+     * with the specified configuration.
+     *
+     * If joinExistingGroup is false, this device sets up a P2P group owner manually (i.e.,
+     * without group owner negotiation with a specific peer) with the specified SSID,
+     * passphrase, persistent mode, and frequency/band.
+     *
+     * If joinExistingGroup is true, this device acts as a group client and joins the group
+     * whose network name and group owner's MAC address matches the specified SSID
+     * and peer address without WPS process. If peerAddress is 00:00:00:00:00:00, the first found
+     * group whose network name matches the specified SSID is joined.
+     *
+     * @param ssid The SSID of this group.
+     * @param pskPassphrase The passphrase of this group.
+     * @param persistent Used to request a persistent group to be formed,
+     *        only applied for the group owner.
+     * @param freq The required frequency or band for this group.
+     *        only applied for the group owner.
+     *        The following values are supported:
+     *        0: automatic channel selection,
+     *        2: for 2.4GHz channels
+     *        5: for 5GHz channels
+     *        specific frequency, i.e., 2412, 5500, etc.
+     *        If an invalid band or unsupported frequency are specified, it fails.
+     * @param peerAddress the group owner's MAC address, only applied for the group client.
+     *        If the MAC is "00:00:00:00:00:00", the device must try to find a peer
+     *        whose network name matches the specified SSID.
+     * @param joinExistingGroup if true, join a group as a group client; otherwise,
+     *        create a group as a group owner.
+     * @return status Status of the operation.
+     *         Possible status codes:
+     *         |SupplicantStatusCode.SUCCESS|,
+     *         |SupplicantStatusCode.FAILURE_UNKNOWN|,
+     *         |SupplicantStatusCode.FAILURE_IFACE_INVALID|
+     */
+    addGroup_1_2(Ssid ssid, string pskPassphrase, bool persistent,
+                 uint32_t freq, MacAddress peerAddress, bool joinExistingGroup)
+        generates (SupplicantStatus status);
+};
diff --git a/wifi/supplicant/1.2/ISupplicantStaIface.hal b/wifi/supplicant/1.2/ISupplicantStaIface.hal
new file mode 100644
index 0000000..a338c6a
--- /dev/null
+++ b/wifi/supplicant/1.2/ISupplicantStaIface.hal
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi.supplicant@1.2;
+
+import @1.0::SupplicantStatus;
+import @1.1::ISupplicantStaIface;
+import @1.2::ISupplicantStaNetwork;
+
+/**
+ * Interface exposed by the supplicant for each station mode network
+ * interface (e.g wlan0) it controls.
+ */
+interface ISupplicantStaIface extends @1.1::ISupplicantStaIface {
+
+    /**
+     * Get Key management capabilities of the device
+     *
+     * @return status Status of the operation, and a bitmap of key management mask.
+     *         Possible status codes:
+     *         |SupplicantStatusCode.SUCCESS|,
+     *         |SupplicantStatusCode.FAILURE_ARGS_INVALID|,
+     *         |SupplicantStatusCode.FAILURE_UNKNOWN|,
+     *         |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
+     */
+    getKeyMgmtCapabilities()
+        generates (SupplicantStatus status, bitfield<KeyMgmtMask> keyMgmtMask);
+};
+
diff --git a/wifi/supplicant/1.2/ISupplicantStaNetwork.hal b/wifi/supplicant/1.2/ISupplicantStaNetwork.hal
index 85b233d..6fd0d51 100644
--- a/wifi/supplicant/1.2/ISupplicantStaNetwork.hal
+++ b/wifi/supplicant/1.2/ISupplicantStaNetwork.hal
@@ -256,17 +256,4 @@
      */
     setSaePasswordId(string saePasswordId)
         generates (SupplicantStatus status);
-
-    /**
-     * Get Key management capabilities of the device
-     *
-     * @return status Status of the operation, and a string.
-     *         Possible status codes:
-     *         |SupplicantStatusCode.SUCCESS|,
-     *         |SupplicantStatusCode.FAILURE_ARGS_INVALID|,
-     *         |SupplicantStatusCode.FAILURE_UNKNOWN|,
-     *         |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
-     */
-    getKeyMgmtCapabilities()
-        generates (SupplicantStatus status, bitfield<KeyMgmtMask> keyMgmtMask);
 };